@dxtmisha/functional 1.15.5 → 1.15.6
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/ai-description.md +7 -29
- package/ai-doc.md +5 -39
- package/ai-mcp.json +26 -0
- package/ai-prompts/api-reference.md +25 -0
- package/ai-prompts/localization-seo.md +29 -0
- package/ai-prompts/reactivity-lists.md +34 -0
- package/ai-prompts/storage-state.md +27 -0
- package/ai-types.md +593 -451
- package/package.json +3 -1
package/ai-types.md
CHANGED
|
@@ -14,132 +14,645 @@ The following is the content of "exports" from package.json:
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
import { ComputedRef, Ref, ShallowRef, ToRefs, VNode, DebuggerOptions, ComputedGetter, Plugin, PropType } from 'vue';
|
|
18
|
+
import { RouteLocationRaw, Router, _RouterClassic } from 'vue-router';
|
|
19
|
+
import { Datetime, GeoDate, GeoFirstDay, GeoHours, NumberOrStringOrDate, ElementOrString, ElementOrWindow, EventItem, EventListenerDetail, EventOptions, GeoFlag, GeoFlagItem, GeoFlagNational, ItemValue, NumberOrString, GeoItemFull, GeoUnit, ApiInstance, ApiData, ApiDataValidation, ApiErrorStorageList, ApiFetch, ArrayToItem, FormattersListColumns, FormattersOptionsList, SearchColumns, SearchFormatList, ApiErrorItem, ApiMethodItem, CookieOptions, FormattersListProp, FormattersReturn, MetaRobots, Meta, NumberOrStringOrBoolean, SearchItem, SearchOptions, TranslateInstance, TranslateList, ApiConfig, ErrorCenterCauseList, ErrorCenterHandlerCallback, ErrorCenterHandlerList, IconsConfig, TranslateConfig, ItemList, Undefined, ApiDefaultValue, SearchListValue } from '@dxtmisha/functional-basic';
|
|
20
|
+
import { InputSocialIcons } from '@dxtmisha/media';
|
|
17
21
|
export * from '@dxtmisha/functional-basic';
|
|
22
|
+
export type RefType<T> = ComputedRef<T> | Ref<T>;
|
|
23
|
+
export type RefUndefined<T> = RefType<T | undefined>;
|
|
24
|
+
export type RefOrNormal<T> = RefType<T> | T;
|
|
25
|
+
export type RefOrNormalOrFunction<T> = RefOrNormal<T> | (() => RefOrNormal<T>);
|
|
26
|
+
export type RawChildren = string | number | boolean | VNode | VNodeArrayChildren | (() => any);
|
|
27
|
+
export type RawSlots = { [name: string]: unknown; $stable?: boolean; };
|
|
28
|
+
export type ApiOptions = ApiMethodItem | RefOrNormal<ApiFetch>;
|
|
29
|
+
export type ApiManagementValue = ApiDefaultValue | ApiDefaultValue[];
|
|
30
|
+
/** Configuration for the main GET request in API management. */
|
|
31
|
+
export type ApiManagementGet<Return extends ApiManagementValue, Type extends ApiManagementValue = Return> = {
|
|
32
|
+
path?: RefOrNormal<string | undefined>;
|
|
33
|
+
options?: ApiOptions;
|
|
34
|
+
reactivity?: boolean;
|
|
35
|
+
conditions?: RefType<boolean>;
|
|
36
|
+
transformation?: (data: Type, isResponseContractValid?: ApiDataValidation) => ApiData<Return>;
|
|
37
|
+
validateResponseContract?: (data: Type) => ApiDataValidation;
|
|
38
|
+
errorContract?: ApiErrorStorageList;
|
|
39
|
+
typeData?: ((data: Return) => boolean) | any;
|
|
40
|
+
unmounted?: boolean;
|
|
41
|
+
skeleton?: () => Return;
|
|
42
|
+
};
|
|
43
|
+
/** Configuration for client-side search across API data. */
|
|
44
|
+
export type ApiManagementSearch<T extends SearchItem, K extends SearchColumns<T>> = {
|
|
45
|
+
columns: K;
|
|
46
|
+
value?: Ref<string>;
|
|
47
|
+
options?: SearchOptions;
|
|
48
|
+
};
|
|
49
|
+
/** Configuration for mutation requests (POST, PUT, DELETE). */
|
|
50
|
+
export type ApiManagementRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> = {
|
|
51
|
+
path?: RefOrNormal<string | undefined>;
|
|
52
|
+
action?: (data: Return | undefined) => Promise<void> | void;
|
|
53
|
+
transformation?: (data: T) => Return;
|
|
54
|
+
validateRequestContract?: (data: Request) => ApiDataValidation & Return;
|
|
55
|
+
validateResponseContract?: (data: T) => ApiDataValidation & Return;
|
|
56
|
+
errorContract?: ApiErrorStorageList;
|
|
57
|
+
toData?: boolean;
|
|
58
|
+
options?: ApiOptions;
|
|
59
|
+
};
|
|
60
|
+
export type ConstrItem = Record<string, any>;
|
|
61
|
+
export type ConstrValue<T = any> = { value?: T; };
|
|
62
|
+
export type ConstrComponent = Record<string, any>;
|
|
63
|
+
export type ConstrComponentMod<P extends ConstrItem> = ConstrItem | { [K in keyof P]?: RefOrNormal<P[K]>; };
|
|
64
|
+
export type ConstrExpose<E extends Element, EXPOSE extends ConstrItem> = EXPOSE & { elementHtml?: ComputedRef<E | undefined>; };
|
|
65
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
66
|
+
export type ConstrEmitItem<T extends ConstrItem> = T[keyof T];
|
|
67
|
+
export type ConstrEmit<T extends ConstrItem = ConstrItem> = UnionToIntersection<ConstrEmitItem<{ [K in keyof T]: (evt: K, ...args: T[K]) => void; }>>;
|
|
68
|
+
export type ConstrClassObject = Record<string, boolean | undefined>;
|
|
69
|
+
export type ConstrClass = string | (string | ConstrClass | Undefined)[] | ConstrClassObject;
|
|
70
|
+
export type ConstrClassList = Record<string, ConstrClass>;
|
|
71
|
+
export type ConstrClasses = { main: ConstrClass; } & ConstrClassList;
|
|
72
|
+
export type ConstrStylesItem = string | null;
|
|
73
|
+
export type ConstrStyles = Record<string, ConstrStylesItem> | ConstrStyles[];
|
|
74
|
+
export type ConstrOptions<COMP extends ConstrComponent, EMITS extends ConstrItem, P extends ConstrItem> = {
|
|
75
|
+
components?: COMP;
|
|
76
|
+
compMod?: ConstrComponentMod<P>;
|
|
77
|
+
emits?: ConstrEmit<EMITS>;
|
|
78
|
+
classes?: RefType<ConstrClasses>;
|
|
79
|
+
styles?: RefType<ConstrStyles>;
|
|
80
|
+
};
|
|
81
|
+
export type ConstrSetup<E extends Element, CLASSES extends ConstrClasses, SETUP extends ConstrItem> = {
|
|
82
|
+
name: string;
|
|
83
|
+
element: Ref<E | undefined>;
|
|
84
|
+
classes: RefType<CLASSES>;
|
|
85
|
+
styles: RefType<ConstrStyles>;
|
|
86
|
+
} & SETUP;
|
|
87
|
+
export type ConstrRegistration = {
|
|
88
|
+
flag?: boolean;
|
|
89
|
+
translate?: Record<string, string>;
|
|
90
|
+
};
|
|
91
|
+
export type ConstrBind<T> = T & Record<string, any> & {
|
|
92
|
+
key?: string;
|
|
93
|
+
class?: ConstrClass;
|
|
94
|
+
style?: ConstrStyles;
|
|
95
|
+
};
|
|
96
|
+
export type ConstrPropItemOptions<T = any> = {
|
|
97
|
+
type?: PropType<T>;
|
|
98
|
+
required?: boolean;
|
|
99
|
+
default?: any;
|
|
100
|
+
validator?(value: any, props: any): boolean;
|
|
101
|
+
};
|
|
102
|
+
export type ConstrPropItem<T = any> = ConstrPropItemOptions<T> | PropType<T>;
|
|
103
|
+
export type ConstrProps<P = Record<string, any>> = { [K in keyof P]: ConstrPropItem<P[K]>; };
|
|
104
|
+
export type ConstrHrefProps = { href?: string; };
|
|
105
|
+
export type ListType = 'item' | 'space' | 'line' | 'subtitle' | 'html' | 'menu' | 'menu-group' | 'group';
|
|
106
|
+
export type ListDataBasic = { label?: NumberOrString; value?: any; search?: string; };
|
|
107
|
+
export type ListDataItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item & { parent?: string; type: ListType; index: string; disabled?: boolean; }>;
|
|
108
|
+
export type ListList<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item>[];
|
|
109
|
+
export type ListRecord<Item extends ListDataBasic = ListDataBasic> = ListList<Item> | Record<string, any>;
|
|
110
|
+
export type ListDataFullItem<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item> & { focus: boolean; highlight?: string; selected: boolean; disabled?: boolean; };
|
|
111
|
+
export type ListDataFull<Item extends ListDataBasic = ListDataBasic> = ListDataFullItem<Item>[];
|
|
112
|
+
export type ListListInputItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item>;
|
|
113
|
+
export type ListListInput<Item extends ListDataBasic = ListDataBasic> = ListListInputItem<Item>[] | string[] | Record<string, ListListInputItem<Item>> | Record<string, string>;
|
|
114
|
+
export type ListSelectedItem = NumberOrStringOrBoolean;
|
|
115
|
+
export type ListSelectedList = ListSelectedItem | ListSelectedItem[];
|
|
116
|
+
export type ListName = string | number | undefined;
|
|
117
|
+
export type ListNames = ListName[];
|
|
118
|
+
export type SearchListValueRef<T extends SearchItem> = RefOrNormal<SearchListValue<T>>;
|
|
119
|
+
export type SearchListInput<T extends SearchItem> = SearchListValueRef<T> | (() => SearchListValueRef<T>);
|
|
120
|
+
export type SearchColumnsRef<T extends SearchItem, K extends SearchColumns<T>> = RefOrNormal<K>;
|
|
121
|
+
export type SearchColumnsInput<T extends SearchItem, K extends SearchColumns<T>> = SearchColumnsRef<T, K> | (() => SearchColumnsRef<T, K>);
|
|
122
|
+
export type LazyItemByMargin = { rootMargin: string; item: ReturnType<typeof useLazyRef>; };
|
|
123
|
+
export type LazyItem = { status: ShallowRef<boolean>; ratio: ShallowRef<number>; entry: ShallowRef<IntersectionObserverEntry | undefined>; stopWatch: () => void; };
|
|
124
|
+
export type LazyList = Record<string, LazyItem>;
|
|
125
|
+
export interface UseApiDeleteSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {}
|
|
126
|
+
export interface UseApiGetSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {}
|
|
127
|
+
export interface UseApiPostSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {}
|
|
128
|
+
export interface UseApiPutSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> extends Omit<UseApiRequestSetup<T, Request, Return>, 'method'> {}
|
|
129
|
+
/** Interface for reactive API request instance. */
|
|
130
|
+
export interface UseApiRef<R> {
|
|
131
|
+
data: ComputedRef<ApiData<R> | undefined>;
|
|
132
|
+
item: Ref<ApiData<R> | undefined>;
|
|
133
|
+
errorItem: ComputedRef<ApiErrorItem | undefined>;
|
|
134
|
+
isResponseContractValid: ComputedRef<boolean>;
|
|
135
|
+
responseValidationResult: ComputedRef<ApiDataValidation | undefined>;
|
|
136
|
+
length: ComputedRef<number>;
|
|
137
|
+
starting: ComputedRef<boolean>;
|
|
138
|
+
loading: Ref<boolean>;
|
|
139
|
+
reading: Ref<boolean>;
|
|
140
|
+
isStarting(): boolean;
|
|
141
|
+
isLoading(): boolean;
|
|
142
|
+
isReading(): boolean;
|
|
143
|
+
getItem(): ApiData<R> | undefined;
|
|
144
|
+
init(): void;
|
|
145
|
+
initSsr(): void;
|
|
146
|
+
reset(): Promise<void>;
|
|
147
|
+
stop(): void;
|
|
148
|
+
abort(): void;
|
|
149
|
+
}
|
|
150
|
+
/** Setup interface for API request. */
|
|
151
|
+
export interface UseApiRequestSetup<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> {
|
|
152
|
+
path?: RefOrNormal<string | undefined>;
|
|
153
|
+
method?: ApiMethodItem;
|
|
154
|
+
action?: (data: Return | undefined) => Promise<void> | void;
|
|
155
|
+
transformation?: (data: T) => Return;
|
|
156
|
+
validateRequestContract?: (data: Request) => ApiDataValidation & Return;
|
|
157
|
+
validateResponseContract?: (data: T) => ApiDataValidation & Return;
|
|
158
|
+
errorContract?: ApiErrorStorageList;
|
|
159
|
+
toData?: boolean;
|
|
160
|
+
options?: ApiOptions;
|
|
161
|
+
apiInstance?: ApiInstance;
|
|
162
|
+
}
|
|
163
|
+
/** Interface for functional plugin configuration options. */
|
|
164
|
+
export interface FunctionalPluginOptions {
|
|
165
|
+
api?: ApiConfig;
|
|
166
|
+
translate?: TranslateConfig;
|
|
167
|
+
location?: string | (() => string);
|
|
168
|
+
metaSuffix?: string;
|
|
169
|
+
icons?: IconsConfig;
|
|
170
|
+
iconsSocial?: InputSocialIcons;
|
|
171
|
+
router?: Router;
|
|
172
|
+
errorCauses?: ErrorCenterCauseList;
|
|
173
|
+
errorHandlers?: ErrorCenterHandlerList;
|
|
174
|
+
errorCallbacks?: ErrorCenterHandlerCallback[];
|
|
175
|
+
}
|
|
176
|
+
/** Base abstract class for design constructor components managing properties, callbacks, and tracked changes. */
|
|
18
177
|
export declare abstract class DesignAbstract<T extends Record<string, any>, C extends Record<string, any>> {
|
|
178
|
+
/**
|
|
179
|
+
* Constructor
|
|
180
|
+
* @param props base data
|
|
181
|
+
* @param callback callback function when the value changes
|
|
182
|
+
* @param changed data for tracking
|
|
183
|
+
*/
|
|
19
184
|
constructor(props: T, callback?: ((event: C) => void) | undefined, changed?: string[]);
|
|
185
|
+
/**
|
|
186
|
+
* Calls the callback function.
|
|
187
|
+
* @param compelled forces data to update
|
|
188
|
+
*/
|
|
20
189
|
make(compelled?: boolean): this;
|
|
190
|
+
/**
|
|
191
|
+
* Calls the callback function.
|
|
192
|
+
* @param compelled forces data to update
|
|
193
|
+
*/
|
|
21
194
|
makeCallback(compelled?: boolean): void;
|
|
22
195
|
}
|
|
196
|
+
/** Base async abstract class for design components with asynchronous initialization. */
|
|
23
197
|
export declare abstract class DesignAsyncAbstract<T extends Record<string, any>, C extends Record<string, any>> extends DesignAbstract<T, C> {
|
|
198
|
+
/**
|
|
199
|
+
* Calls the callback function.
|
|
200
|
+
* @param compelled forces data to update
|
|
201
|
+
*/
|
|
24
202
|
make(compelled?: boolean): this;
|
|
203
|
+
/**
|
|
204
|
+
* Calls the callback function.
|
|
205
|
+
* @param compelled forces data to update
|
|
206
|
+
*/
|
|
25
207
|
makeCallback(compelled?: boolean): Promise<void>;
|
|
26
208
|
}
|
|
209
|
+
/** Class for tracking edited/changed values. */
|
|
27
210
|
export declare class DesignChanged<T extends Record<string, any>> {
|
|
211
|
+
/**
|
|
212
|
+
* Constructor
|
|
213
|
+
* @param props base data
|
|
214
|
+
* @param watch data for tracking
|
|
215
|
+
*/
|
|
28
216
|
constructor(props: T, watch?: string[]);
|
|
217
|
+
/**
|
|
218
|
+
* Checks if the value has been updated.
|
|
219
|
+
* @param name property name
|
|
220
|
+
*/
|
|
29
221
|
is(name: string | string[]): boolean;
|
|
222
|
+
/** Checks if there are changes in the data. */
|
|
30
223
|
isChanged(): boolean;
|
|
224
|
+
/** Updates all values. */
|
|
31
225
|
update(): void;
|
|
32
226
|
}
|
|
227
|
+
/** Component wrapper class extending DesignComponents. */
|
|
33
228
|
export declare class DesignComp<COMP extends ConstrComponent, P extends ConstrItem> extends DesignComponents<COMP, P> {}
|
|
229
|
+
/** Class for working with connected components. */
|
|
34
230
|
export declare class DesignComponents<COMP extends ConstrComponent, P extends ConstrItem> {
|
|
231
|
+
/**
|
|
232
|
+
* Constructor
|
|
233
|
+
* @param components list of connected components
|
|
234
|
+
* @param modification data for modification
|
|
235
|
+
*/
|
|
35
236
|
constructor(components?: COMP, modification?: ConstrComponentMod<P> | undefined);
|
|
237
|
+
/**
|
|
238
|
+
* Check the presence of the component.
|
|
239
|
+
* @param name name of the component
|
|
240
|
+
*/
|
|
36
241
|
is<K extends keyof COMP>(name: K): name is K;
|
|
242
|
+
/**
|
|
243
|
+
* Getting the object of the component.
|
|
244
|
+
* @param name name of the component
|
|
245
|
+
*/
|
|
37
246
|
get<K extends keyof COMP>(name: K): COMP[K];
|
|
247
|
+
/**
|
|
248
|
+
* Returns the modified input data of the connected components.
|
|
249
|
+
* @param index the name of this
|
|
250
|
+
* @param props basic data
|
|
251
|
+
*/
|
|
38
252
|
getModification<K extends keyof P>(index?: K & string | string, props?: P[K] | Record<string, any>): Record<string, any> | undefined;
|
|
253
|
+
/**
|
|
254
|
+
* Rendering a component by its name and returning an array with one component.
|
|
255
|
+
* @param name name of the component
|
|
256
|
+
* @param props property of the component
|
|
257
|
+
* @param children sub-elements of the component
|
|
258
|
+
* @param index the name of the key
|
|
259
|
+
*/
|
|
39
260
|
render<K extends keyof COMP, PK extends keyof P>(name: K & string, props?: P[PK] & ConstrItem | ConstrItem, children?: RawChildren | RawSlots, index?: PK & string | string): VNode[];
|
|
261
|
+
/**
|
|
262
|
+
* Rendering a component by its name.
|
|
263
|
+
* @param name name of the component
|
|
264
|
+
* @param props property of the component
|
|
265
|
+
* @param children sub-elements of the component
|
|
266
|
+
* @param index the name of the key
|
|
267
|
+
*/
|
|
40
268
|
renderOne<K extends keyof COMP, PK extends keyof P>(name: K & string, props?: P[PK] & ConstrItem | ConstrItem, children?: RawChildren | RawSlots, index?: PK & string | string): VNode | undefined;
|
|
269
|
+
/**
|
|
270
|
+
* Rendering the component by its name.
|
|
271
|
+
* @param item an array to which the rendered object will be added
|
|
272
|
+
* @param name name of the component
|
|
273
|
+
* @param props property of the component
|
|
274
|
+
* @param children sub-elements of the component
|
|
275
|
+
* @param index the name of the key
|
|
276
|
+
*/
|
|
41
277
|
renderAdd<K extends keyof COMP, PK extends keyof P>(item: any[], name: K & string, props?: P[PK] & ConstrItem | ConstrItem, children?: RawChildren | RawSlots, index?: PK & string | string): this;
|
|
42
278
|
}
|
|
279
|
+
/** Class for collecting all functional components. */
|
|
43
280
|
export declare abstract class DesignConstructorAbstract<E extends Element, COMP extends ConstrComponent, EMITS extends ConstrItem, EXPOSE extends ConstrItem, SLOTS extends ConstrItem, CLASSES extends ConstrClasses, P extends ConstrItem> {
|
|
281
|
+
/** Getting the class name. */
|
|
44
282
|
getName(): string;
|
|
283
|
+
/** Getting the design name. */
|
|
45
284
|
getDesign(): string;
|
|
285
|
+
/**
|
|
286
|
+
* Getting the class name.
|
|
287
|
+
* @param name list of class names by levels
|
|
288
|
+
*/
|
|
46
289
|
getSubClass(name: string | string[]): string;
|
|
290
|
+
/**
|
|
291
|
+
* Getting the class name for the status.
|
|
292
|
+
* @param name list of class names by levels
|
|
293
|
+
*/
|
|
47
294
|
getStatusClass(name: string | string[]): string;
|
|
295
|
+
/**
|
|
296
|
+
* Getting the property name for the style.
|
|
297
|
+
* @param name list of class names by levels
|
|
298
|
+
*/
|
|
48
299
|
getStyle(name: string | string[]): string;
|
|
300
|
+
/** Getting additional parameters. */
|
|
49
301
|
getAttrs(): ConstrItem;
|
|
302
|
+
/** List of available external variables. */
|
|
50
303
|
expose(): ConstrExpose<E, EXPOSE>;
|
|
304
|
+
/** The rendering method for the setup method. */
|
|
51
305
|
render(): () => VNode | (VNode | any)[] | undefined;
|
|
52
306
|
}
|
|
307
|
+
/** A class for working with dates reactively. */
|
|
53
308
|
export declare class DatetimeRef {
|
|
309
|
+
/**
|
|
310
|
+
* Constructor
|
|
311
|
+
* @param date date for processing
|
|
312
|
+
* @param type type of date format for output
|
|
313
|
+
* @param code country and language code
|
|
314
|
+
*/
|
|
54
315
|
constructor(date: RefOrNormal<NumberOrStringOrDate>, type?: RefOrNormal<GeoDate>, code?: RefOrNormal<string>);
|
|
316
|
+
/** Returns the basic data for the date. */
|
|
55
317
|
getItem(): Ref<NumberOrStringOrDate>;
|
|
318
|
+
/** Returns a Date object. */
|
|
56
319
|
getDate(): Ref<Date>;
|
|
320
|
+
/** Obtaining an object of the basic Datetime class. */
|
|
57
321
|
getDatetime(): Datetime;
|
|
322
|
+
/** Returns the format of hours. */
|
|
58
323
|
getHoursType(): ComputedRef<GeoHours>;
|
|
324
|
+
/** Returns the code of the first day of the week. */
|
|
59
325
|
getFirstDayCode(): ComputedRef<GeoFirstDay>;
|
|
326
|
+
/** The method returns the year of the specified date according to local time. */
|
|
60
327
|
getYear(): ComputedRef<number>;
|
|
328
|
+
/** The method returns the month in the specified date according to local time. */
|
|
61
329
|
getMonth(): ComputedRef<number>;
|
|
330
|
+
/** The method returns the day of the month for the specified date according to local time. */
|
|
62
331
|
getDay(): ComputedRef<number>;
|
|
332
|
+
/** The method returns the hour for the specified date, according to local time. */
|
|
63
333
|
getHour(): ComputedRef<number>;
|
|
334
|
+
/** The method returns the minutes in the specified date according to local time. */
|
|
64
335
|
getMinute(): ComputedRef<number>;
|
|
336
|
+
/** The method returns the seconds in the specified date according to local time. */
|
|
65
337
|
getSecond(): ComputedRef<number>;
|
|
338
|
+
/** Returns the last day of the week. */
|
|
66
339
|
getMaxDay(): ComputedRef<number>;
|
|
340
|
+
/**
|
|
341
|
+
* Enables language-sensitive date and time formatting.
|
|
342
|
+
* @param type type of date format for output
|
|
343
|
+
* @param styleOptions the representation of the month
|
|
344
|
+
*/
|
|
67
345
|
locale(type?: GeoDate, styleOptions?: Intl.DateTimeFormatOptions['month'] | Intl.DateTimeFormatOptions): ComputedRef<string>;
|
|
346
|
+
/**
|
|
347
|
+
* Output of standard data.
|
|
348
|
+
* @param timeZone add time zone
|
|
349
|
+
*/
|
|
68
350
|
standard(timeZone?: boolean): ComputedRef<string>;
|
|
69
351
|
}
|
|
352
|
+
/** Global effect scope class. */
|
|
70
353
|
export declare class EffectScopeGlobal {
|
|
354
|
+
/**
|
|
355
|
+
* Runs a function within the global scope.
|
|
356
|
+
* @param fn function
|
|
357
|
+
* @returns the return value of the function
|
|
358
|
+
*/
|
|
71
359
|
static run<T>(fn: () => T): T | undefined;
|
|
72
360
|
}
|
|
361
|
+
/** Class for working with events (Ref). */
|
|
73
362
|
export declare class EventRef<E extends ElementOrWindow, O extends Event, D extends Record<string, any> = Record<string, any>> extends EventItem<E, O, D> {
|
|
363
|
+
/**
|
|
364
|
+
* Classes Constructor
|
|
365
|
+
* @param elementSelector element
|
|
366
|
+
* @param elementSelectorControl control element
|
|
367
|
+
* @param type type
|
|
368
|
+
* @param listener event listener callback
|
|
369
|
+
* @param options event listener characteristics
|
|
370
|
+
* @param detail event-dependent detail value
|
|
371
|
+
*/
|
|
74
372
|
constructor(elementSelector?: RefOrNormal<ElementOrString<E> | undefined>, elementSelectorControl?: RefOrNormal<ElementOrString<HTMLElement>>, type?: string | string[], listener?: EventListenerDetail<O, D>, options?: EventOptions, detail?: D);
|
|
75
373
|
}
|
|
374
|
+
/** Class for working with Flags. */
|
|
76
375
|
export declare class GeoFlagRef {
|
|
376
|
+
/**
|
|
377
|
+
* Constructor.
|
|
378
|
+
* @param code country and language code
|
|
379
|
+
*/
|
|
77
380
|
constructor(code?: RefOrNormal<string | undefined>);
|
|
381
|
+
/**
|
|
382
|
+
* Getting the country code.
|
|
383
|
+
* @returns country code
|
|
384
|
+
*/
|
|
78
385
|
getCode(): string;
|
|
386
|
+
/**
|
|
387
|
+
* Returns information about the country and its flag.
|
|
388
|
+
* @param code country code
|
|
389
|
+
*/
|
|
79
390
|
get(code?: RefOrNormal<string>): ComputedRef<GeoFlagItem | undefined>;
|
|
391
|
+
/**
|
|
392
|
+
* Returns information about the language and its flag.
|
|
393
|
+
* @param code country code
|
|
394
|
+
*/
|
|
80
395
|
getLanguage(code?: RefOrNormal<string>): ComputedRef<GeoFlagItem | undefined>;
|
|
396
|
+
/**
|
|
397
|
+
* Getting a link to the flag.
|
|
398
|
+
* @param code country code
|
|
399
|
+
*/
|
|
81
400
|
getFlag(code?: RefOrNormal<string>): ComputedRef<string | undefined>;
|
|
401
|
+
/**
|
|
402
|
+
* Getting a list of countries by an array of codes.
|
|
403
|
+
* @param codes list of country codes
|
|
404
|
+
*/
|
|
82
405
|
getList(codes?: RefOrNormal<string[] | undefined>): ComputedRef<GeoFlagItem[]>;
|
|
406
|
+
/**
|
|
407
|
+
* Getting a list of languages by an array of codes.
|
|
408
|
+
* @param codes list of country codes
|
|
409
|
+
*/
|
|
83
410
|
getListLanguage(codes?: RefOrNormal<string[] | undefined>): ComputedRef<GeoFlagItem[]>;
|
|
411
|
+
/**
|
|
412
|
+
* Getting a list of countries by an array of codes in national language.
|
|
413
|
+
* @param codes list of country codes
|
|
414
|
+
*/
|
|
84
415
|
getNational(codes?: RefOrNormal<string[] | undefined>): ComputedRef<GeoFlagNational[]>;
|
|
416
|
+
/**
|
|
417
|
+
* Getting a list of languages by an array of codes in national language.
|
|
418
|
+
* @param codes list of country codes
|
|
419
|
+
*/
|
|
85
420
|
getNationalLanguage(codes?: RefOrNormal<string[] | undefined>): ComputedRef<GeoFlagNational[]>;
|
|
86
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* Reactive class for managing the formatting of numbers and dates.
|
|
424
|
+
* @remarks
|
|
425
|
+
* Avoid using this reactive class if reactive updates are not required.
|
|
426
|
+
* For non-reactive formatting, use the standard `GeoIntl` class from `@dxtmisha/functional-basic`.
|
|
427
|
+
*/
|
|
87
428
|
export declare class GeoIntlRef {
|
|
429
|
+
/**
|
|
430
|
+
* Constructor
|
|
431
|
+
* @param code country code, full form language-country or one of them
|
|
432
|
+
*/
|
|
88
433
|
constructor(code?: RefOrNormal<string>);
|
|
434
|
+
/**
|
|
435
|
+
* The consistent translation of language, region and script display names.
|
|
436
|
+
* @param value the code to provide depends on the type
|
|
437
|
+
* @param typeOptions options object or type string
|
|
438
|
+
*/
|
|
89
439
|
display(value?: RefOrNormal<string>, typeOptions?: Intl.DisplayNamesOptions['type'] | Intl.DisplayNamesOptions): ComputedRef<string>;
|
|
440
|
+
/**
|
|
441
|
+
* Get display names of language.
|
|
442
|
+
* @param value the code to provide depends on the type
|
|
443
|
+
* @param style the formatting style to use
|
|
444
|
+
*/
|
|
90
445
|
languageName(value?: RefOrNormal<string>, style?: Intl.RelativeTimeFormatStyle): ComputedRef<string>;
|
|
446
|
+
/**
|
|
447
|
+
* Get display names of region.
|
|
448
|
+
* @param value the code to provide depends on the type
|
|
449
|
+
* @param style the formatting style to use
|
|
450
|
+
*/
|
|
91
451
|
countryName(value?: RefOrNormal<string>, style?: Intl.RelativeTimeFormatStyle): ComputedRef<string>;
|
|
452
|
+
/**
|
|
453
|
+
* In basic use without specifying a locale, a formatted string.
|
|
454
|
+
* @param value a number, bigint, or string, to format
|
|
455
|
+
* @param options format options
|
|
456
|
+
*/
|
|
92
457
|
number(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
458
|
+
/** Decimal point symbol. */
|
|
93
459
|
decimal(): ComputedRef<string>;
|
|
460
|
+
/**
|
|
461
|
+
* Currency formatting.
|
|
462
|
+
* @param value a number, bigint, or string, to format
|
|
463
|
+
* @param currencyOptions currency code or options
|
|
464
|
+
* @param numberOnly do not display currency symbol
|
|
465
|
+
*/
|
|
94
466
|
currency(value: RefOrNormal<NumberOrString>, currencyOptions?: RefOrNormal<string | Intl.NumberFormatOptions>, numberOnly?: boolean): ComputedRef<string>;
|
|
467
|
+
/**
|
|
468
|
+
* Returns the currency symbol if it exists, otherwise the currency code.
|
|
469
|
+
* @param currency currency code
|
|
470
|
+
* @param currencyDisplay display mode
|
|
471
|
+
*/
|
|
95
472
|
currencySymbol(currency: RefOrNormal<string>, currencyDisplay?: keyof Intl.NumberFormatOptionsCurrencyDisplayRegistry): ComputedRef<string>;
|
|
473
|
+
/**
|
|
474
|
+
* Unit formatting.
|
|
475
|
+
* @param value a number, bigint, or string, to format
|
|
476
|
+
* @param unitOptions unit identifier or options
|
|
477
|
+
*/
|
|
96
478
|
unit(value: RefOrNormal<NumberOrString>, unitOptions?: string | Intl.NumberFormatOptions): ComputedRef<string>;
|
|
479
|
+
/**
|
|
480
|
+
* Returns formatted file size.
|
|
481
|
+
* @param value size number
|
|
482
|
+
* @param unitOptions unit options
|
|
483
|
+
*/
|
|
97
484
|
sizeFile(value: RefOrNormal<NumberOrString>, unitOptions?: 'byte' | 'kilobyte' | 'megabyte' | 'gigabyte' | 'terabyte' | 'petabyte' | Intl.NumberFormatOptions): ComputedRef<string>;
|
|
485
|
+
/**
|
|
486
|
+
* Number as a percentage.
|
|
487
|
+
* @param value number to format
|
|
488
|
+
* @param options format options
|
|
489
|
+
*/
|
|
98
490
|
percent(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
491
|
+
/**
|
|
492
|
+
* Number as a percentage (unit).
|
|
493
|
+
* @param value number to format
|
|
494
|
+
* @param options format options
|
|
495
|
+
*/
|
|
99
496
|
percentBy100(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
497
|
+
/**
|
|
498
|
+
* Formats plural rules based on input number and words list.
|
|
499
|
+
* @param value number to format
|
|
500
|
+
* @param words formatted words separated by pipeline
|
|
501
|
+
* @param options plural rules options
|
|
502
|
+
* @param optionsNumber number format options
|
|
503
|
+
*/
|
|
100
504
|
plural(value: RefOrNormal<NumberOrString>, words: string, options?: Intl.PluralRulesOptions, optionsNumber?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
505
|
+
/**
|
|
506
|
+
* Enables language-sensitive date and time formatting.
|
|
507
|
+
* @param value date to format
|
|
508
|
+
* @param type type of data format
|
|
509
|
+
* @param styleOptions representation of month or options
|
|
510
|
+
* @param hour24 whether to use 24-hour time
|
|
511
|
+
*/
|
|
101
512
|
date(value: RefOrNormal<NumberOrStringOrDate>, type?: GeoDate, styleOptions?: Intl.DateTimeFormatOptions['month'] | Intl.DateTimeFormatOptions, hour24?: boolean): ComputedRef<string>;
|
|
513
|
+
/**
|
|
514
|
+
* Enables language-sensitive relative time formatting.
|
|
515
|
+
* @param value number or date to format
|
|
516
|
+
* @param styleOptions style options
|
|
517
|
+
* @param todayValue reference current date
|
|
518
|
+
*/
|
|
102
519
|
relative(value: RefOrNormal<NumberOrStringOrDate>, styleOptions?: Intl.RelativeTimeFormatStyle | Intl.RelativeTimeFormatOptions, todayValue?: Date): ComputedRef<string>;
|
|
520
|
+
/**
|
|
521
|
+
* Enables relative time formatting with limit checks.
|
|
522
|
+
* @param value number or date to format
|
|
523
|
+
* @param limit day limit threshold
|
|
524
|
+
* @param todayValue reference current date
|
|
525
|
+
* @param relativeOptions relative options
|
|
526
|
+
* @param dateOptions date options
|
|
527
|
+
* @param type date format type
|
|
528
|
+
* @param hour24 24-hour flag
|
|
529
|
+
*/
|
|
103
530
|
relativeLimit(value: RefOrNormal<NumberOrStringOrDate>, limit: number, todayValue?: Date, relativeOptions?: Intl.RelativeTimeFormatStyle | Intl.RelativeTimeFormatOptions, dateOptions?: Intl.DateTimeFormatOptions['month'] | Intl.DateTimeFormatOptions, type?: GeoDate, hour24?: boolean): ComputedRef<string>;
|
|
531
|
+
/**
|
|
532
|
+
* Formats relative time elapsed from value.
|
|
533
|
+
* @param value number to format
|
|
534
|
+
* @param unit relative time unit
|
|
535
|
+
* @param styleOptions style options
|
|
536
|
+
*/
|
|
104
537
|
relativeByValue(value: RefOrNormal<NumberOrString>, unit: Intl.RelativeTimeFormatUnit, styleOptions?: Intl.RelativeTimeFormatStyle | Intl.RelativeTimeFormatOptions): ComputedRef<string>;
|
|
538
|
+
/**
|
|
539
|
+
* Names of months.
|
|
540
|
+
* @param value date
|
|
541
|
+
* @param style month style
|
|
542
|
+
*/
|
|
105
543
|
month(value?: RefOrNormal<NumberOrStringOrDate>, style?: Intl.DateTimeFormatOptions['month']): ComputedRef<string>;
|
|
544
|
+
/**
|
|
545
|
+
* List of months.
|
|
546
|
+
* @param style month style
|
|
547
|
+
*/
|
|
106
548
|
months(style?: Intl.DateTimeFormatOptions['month']): ComputedRef<ItemValue<number | undefined>[]>;
|
|
549
|
+
/**
|
|
550
|
+
* Returns weekday name.
|
|
551
|
+
* @param value date
|
|
552
|
+
* @param style weekday style
|
|
553
|
+
*/
|
|
107
554
|
weekday(value?: RefOrNormal<NumberOrStringOrDate>, style?: Intl.DateTimeFormatOptions['weekday']): ComputedRef<string>;
|
|
555
|
+
/**
|
|
556
|
+
* List of weekday names.
|
|
557
|
+
* @param style weekday style
|
|
558
|
+
*/
|
|
108
559
|
weekdays(style?: Intl.DateTimeFormatOptions['weekday']): ComputedRef<ItemValue<number | undefined>[]>;
|
|
560
|
+
/**
|
|
561
|
+
* Formatted time string.
|
|
562
|
+
* @param value date
|
|
563
|
+
*/
|
|
109
564
|
time(value: RefOrNormal<NumberOrStringOrDate>): ComputedRef<string>;
|
|
565
|
+
/**
|
|
566
|
+
* Sorts strings taking into account the characteristics of countries.
|
|
567
|
+
* @param data array data
|
|
568
|
+
* @param compareFn comparison function
|
|
569
|
+
*/
|
|
110
570
|
sort<T>(data: RefOrNormal<T[]>, compareFn?: (a: T, b: T) => [string, string]): ComputedRef<T[]>;
|
|
111
571
|
}
|
|
572
|
+
/** Reactive class for working with geographic data. */
|
|
112
573
|
export declare class GeoRef {
|
|
574
|
+
/** Information about the current country. */
|
|
113
575
|
static get(): Ref<GeoItemFull>;
|
|
576
|
+
/** Current country code. */
|
|
114
577
|
static getCountry(): ComputedRef<string>;
|
|
578
|
+
/** Current language code. */
|
|
115
579
|
static getLanguage(): ComputedRef<string>;
|
|
580
|
+
/** Full standard locale format. */
|
|
116
581
|
static getStandard(): ComputedRef<string>;
|
|
582
|
+
/** First day of week code. */
|
|
117
583
|
static getFirstDay(): ComputedRef<string>;
|
|
584
|
+
/** Current location string. */
|
|
118
585
|
static getLocation(): ComputedRef<string>;
|
|
586
|
+
/** Current country code from location. */
|
|
119
587
|
static getLocationCountry(): ComputedRef<string>;
|
|
588
|
+
/** Current language code from location. */
|
|
120
589
|
static getLocationLanguage(): ComputedRef<string>;
|
|
590
|
+
/**
|
|
591
|
+
* Changes the data by full code.
|
|
592
|
+
* @param code location code
|
|
593
|
+
*/
|
|
121
594
|
static set(code: string): void;
|
|
595
|
+
/**
|
|
596
|
+
* Sets default country code.
|
|
597
|
+
* @param code default code or getter
|
|
598
|
+
*/
|
|
122
599
|
static setValueDefault(code?: string | (() => string)): void;
|
|
123
600
|
}
|
|
601
|
+
/** Reactive class for managing localized unit formatting and automatic conversions. */
|
|
124
602
|
export declare class GeoUnitRef {
|
|
603
|
+
/**
|
|
604
|
+
* Constructor.
|
|
605
|
+
* @param code location code
|
|
606
|
+
*/
|
|
125
607
|
constructor(code?: RefOrNormal<string>);
|
|
608
|
+
/** Standard location code. */
|
|
126
609
|
getLocation(): ComputedRef<string>;
|
|
610
|
+
/** Formats millimeter value. */
|
|
127
611
|
millimeter(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
612
|
+
/** Formats centimeter value. */
|
|
128
613
|
centimeter(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
614
|
+
/** Formats meter value. */
|
|
129
615
|
meter(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
616
|
+
/** Formats kilometer value. */
|
|
130
617
|
kilometer(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
618
|
+
/** Formats square meter value. */
|
|
131
619
|
squareMeter(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
620
|
+
/** Formats hectare value. */
|
|
132
621
|
hectare(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
622
|
+
/** Formats gram value. */
|
|
133
623
|
gram(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
624
|
+
/** Formats kilogram value. */
|
|
134
625
|
kilogram(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
626
|
+
/** Formats tonne value. */
|
|
135
627
|
tonne(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
628
|
+
/** Formats milliliter value. */
|
|
136
629
|
milliliter(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
630
|
+
/** Formats liter value. */
|
|
137
631
|
liter(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
632
|
+
/** Formats celsius value. */
|
|
138
633
|
celsius(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
634
|
+
/** Formats kilometer per hour value. */
|
|
139
635
|
kilometerPerHour(value: RefOrNormal<NumberOrString>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
636
|
+
/** Formats custom unit value. */
|
|
140
637
|
format(value: RefOrNormal<NumberOrString>, unit: RefOrNormal<string>, options?: Intl.NumberFormatOptions): ComputedRef<string>;
|
|
141
638
|
}
|
|
639
|
+
/** Class for managing list data structure and navigation. */
|
|
142
640
|
export declare class ListDataRef {
|
|
641
|
+
/**
|
|
642
|
+
* Constructor
|
|
643
|
+
* @param list list data
|
|
644
|
+
* @param focus focus identifier
|
|
645
|
+
* @param highlight search highlight text
|
|
646
|
+
* @param highlightLengthStart min length to highlight
|
|
647
|
+
* @param filterMode filter mode flag
|
|
648
|
+
* @param selected selected identifiers
|
|
649
|
+
* @param keyValue value key name
|
|
650
|
+
* @param keyLabel label key name
|
|
651
|
+
* @param lite lite mode threshold
|
|
652
|
+
* @param min minimum selection
|
|
653
|
+
* @param max maximum selection
|
|
654
|
+
* @param parent parent identifier
|
|
655
|
+
*/
|
|
143
656
|
constructor(list: RefOrNormal<ListListInput | undefined>, focus?: RefType<ListSelectedItem | undefined> | undefined, highlight?: RefType<string | undefined> | undefined, highlightLengthStart?: RefType<number | undefined> | undefined, filterMode?: RefType<boolean | undefined> | undefined, selected?: RefType<ListSelectedList | undefined> | undefined, keyValue?: RefType<string | undefined> | undefined, keyLabel?: RefType<string | undefined> | undefined, lite?: RefType<number | undefined> | undefined, min?: RefOrNormal<number | string | undefined>, max?: RefOrNormal<number | string | undefined>, parent?: string | undefined);
|
|
144
657
|
readonly data: ComputedRef<ListList>;
|
|
145
658
|
readonly liteData: ComputedRef<ListList>;
|
|
@@ -176,24 +689,30 @@ export declare class ListDataRef {
|
|
|
176
689
|
getIndexByStep(index: string, step: number): ListDataItem | undefined;
|
|
177
690
|
getIndexNext(index: string): ListDataItem | undefined;
|
|
178
691
|
getIndexPrev(index: string): ListDataItem | undefined;
|
|
179
|
-
getItemByIndex(index?: string): {
|
|
180
|
-
key: number;
|
|
181
|
-
item: ListDataItem;
|
|
182
|
-
} | undefined;
|
|
692
|
+
getItemByIndex(index?: string): { key: number; item: ListDataItem; } | undefined;
|
|
183
693
|
getItemByKey(key: number): ListDataItem | undefined;
|
|
184
694
|
getFirstItemByParent(parent: string | undefined): ListDataItem | undefined;
|
|
185
695
|
getLastItemByParent(parent: string | undefined): ListDataItem | undefined;
|
|
186
696
|
getSubList(item: ListDataItem): ListDataRef;
|
|
187
697
|
}
|
|
698
|
+
/** Router management class. */
|
|
188
699
|
export declare class RouterItemRef {
|
|
700
|
+
/** Get router instance. */
|
|
189
701
|
static get(): _RouterClassic;
|
|
702
|
+
/** Returns link by route name. */
|
|
190
703
|
static getLink(name: string, params?: any, query?: any): string | undefined;
|
|
704
|
+
/** Returns href properties by route name. */
|
|
191
705
|
static getHref(name?: string, params?: any, query?: any): ConstrHrefProps;
|
|
706
|
+
/** Changes site path. */
|
|
192
707
|
static push(to: string | RouteLocationRaw): void;
|
|
708
|
+
/** Sets router instance. */
|
|
193
709
|
static set(router: Router): void;
|
|
710
|
+
/** Sets router instance once. */
|
|
194
711
|
static setOneTime(router: Router): void;
|
|
712
|
+
/** Converts raw location to href properties. */
|
|
195
713
|
static rawToHref(to?: string | RouteLocationRaw): ConstrHrefProps;
|
|
196
714
|
}
|
|
715
|
+
/** Class for getting scrollbar width as a reactive item. */
|
|
197
716
|
export declare class ScrollbarWidthRef {
|
|
198
717
|
readonly item: Ref<boolean | undefined, boolean | undefined>;
|
|
199
718
|
readonly width: Ref<number, number>;
|
|
@@ -202,64 +721,23 @@ export declare class ScrollbarWidthRef {
|
|
|
202
721
|
}
|
|
203
722
|
/**
|
|
204
723
|
* Asynchronous reactive composable for API requests with built-in SSR support.
|
|
205
|
-
* Wraps `useApiRef` and immediately calls `initSsr()` to ensure data is pre-fetched on the server side.
|
|
206
|
-
* Use this composable ONLY if you need the request to be executed on the server side during SSR.
|
|
207
|
-
* For all other cases, use `useApiRef`.
|
|
208
|
-
*
|
|
209
724
|
* @example
|
|
210
725
|
* ```typescript
|
|
211
|
-
*
|
|
212
|
-
* import { useApiAsyncRef } from '@dxtmisha/functional'
|
|
213
|
-
*
|
|
214
|
-
* const userSchema = S.Struct({ id: S.Number, name: S.String })
|
|
215
|
-
*
|
|
216
|
-
* // Data will be pre-fetched on the server during SSR (onServerPrefetch)
|
|
217
|
-
* const { data, loading, errorItem, isResponseContractValid } = useApiAsyncRef(
|
|
218
|
-
* '/users/1',
|
|
219
|
-
* { method: 'GET' },
|
|
220
|
-
* true, // reactivity
|
|
221
|
-
* undefined, // conditions
|
|
222
|
-
* undefined, // transformation
|
|
223
|
-
* (data) => { // validateResponseContract
|
|
224
|
-
* try {
|
|
225
|
-
* return { status: 'success', data: S.decodeUnknownSync(userSchema)(data) }
|
|
226
|
-
* } catch (e) {
|
|
227
|
-
* return { status: 'error', errors: e }
|
|
228
|
-
* }
|
|
229
|
-
* },
|
|
230
|
-
* [ // errorContract
|
|
231
|
-
* { status: 404, message: 'User not found' }
|
|
232
|
-
* ]
|
|
233
|
-
* )
|
|
726
|
+
* const { data, loading } = useApiAsyncRef('/users/1', { method: 'GET' });
|
|
234
727
|
* ```
|
|
235
|
-
*
|
|
236
|
-
* @param path path to request (can be a Ref or Getter)
|
|
237
|
-
* @param options data for the request (headers, method, etc.)
|
|
238
|
-
* @param reactivity should reactivity be enabled (automatically re-fetch on deps change)
|
|
239
|
-
* @param conditions conditions for executing the request (request will wait until true)
|
|
240
|
-
* @param transformation transforms the received response data
|
|
241
|
-
* @param validateResponseContract function to validate response data contract. Used to ensure that the API
|
|
242
|
-
* response matches the expected structure. Highly recommended to use with `@effect/schema`.
|
|
243
|
-
* It should return `ApiDataValidation` containing a `status` ('success' or 'error')
|
|
244
|
-
* and the parsed data or errors.
|
|
245
|
-
* @param errorContract array of expected error contracts for the request (`ApiErrorStorageList`).
|
|
246
|
-
* Highly recommended to add if there is information about possible request errors. Allows you to predefine
|
|
247
|
-
* possible errors (by code, status, or custom validation). If an error occurs matching one of these contracts,
|
|
248
|
-
* it will be automatically processed and made available via the `errorItem` computed property.
|
|
249
|
-
* @param unmounted whether to stop the request and clear data from cache when component is unmounted
|
|
250
|
-
* @param apiInstance Api instance (defaults to global Api instance)
|
|
251
728
|
*/
|
|
252
729
|
export declare function useApiAsyncRef<R, T = R>(path?: RefOrNormal<string | undefined>, options?: ApiOptions, reactivity?: boolean, conditions?: RefType<boolean>, transformation?: (data: T, isResponseContractValid?: ApiDataValidation) => ApiData<R>, validateResponseContract?: (data: T) => ApiDataValidation, errorContract?: ApiErrorStorageList, unmounted?: boolean, apiInstance?: ApiInstance): UseApiRef<R>;
|
|
253
|
-
|
|
730
|
+
/** Use API delete request helper wrapper. */
|
|
254
731
|
export declare function useApiDelete<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiDeleteSetup<T, Request, Return>): {
|
|
255
732
|
loading: Ref<boolean, boolean>;
|
|
256
733
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
257
734
|
};
|
|
258
|
-
|
|
735
|
+
/** Use API get request helper wrapper. */
|
|
259
736
|
export declare function useApiGet<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiGetSetup<T, Request, Return>): {
|
|
260
737
|
loading: Ref<boolean, boolean>;
|
|
261
738
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
262
739
|
};
|
|
740
|
+
/** Asynchronous reactive composable for API management requests with built-in SSR support. */
|
|
263
741
|
export declare function useApiManagementAsyncRef<Return extends ApiManagementValue, FormattersOptions extends FormattersOptionsList, Post extends Record<string, any>, Put extends Record<string, any>, Delete extends Record<string, any>, Type extends ApiManagementValue = Return, Item extends ArrayToItem<Return> = ArrayToItem<Return>, ItemFormatters extends FormattersListColumns<Item, FormattersOptions>[number] = FormattersListColumns<Item, FormattersOptions>[number], Columns extends SearchColumns<ItemFormatters> = []>(propsGet: ApiManagementGet<Return, Type>, formattersOptions?: FormattersOptions, searchOptions?: ApiManagementSearch<Item, Columns>, postRequest?: ApiManagementRequest<Post>, putRequest?: ApiManagementRequest<Put>, deleteRequest?: ApiManagementRequest<Delete>, action?: () => Promise<void> | void, apiInstance?: ApiInstance): {
|
|
264
742
|
isValid: ComputedRef<boolean>;
|
|
265
743
|
isResponseContractValid: ComputedRef<boolean>;
|
|
@@ -288,63 +766,14 @@ export declare function useApiManagementAsyncRef<Return extends ApiManagementVal
|
|
|
288
766
|
};
|
|
289
767
|
/**
|
|
290
768
|
* A powerful composable for comprehensive API request orchestration.
|
|
291
|
-
* It centrally manages data loading (GET), list formatting, client-side searching,
|
|
292
|
-
* and mutations (POST, PUT, DELETE) through a single reactive interface.
|
|
293
|
-
*
|
|
294
|
-
* @template Return type of data returned by the API
|
|
295
|
-
* @template FormattersOptions optional formatting rules
|
|
296
|
-
* @template Post data type for POST creation request
|
|
297
|
-
* @template Put data type for PUT update request
|
|
298
|
-
* @template Delete data type for DELETE removal request
|
|
299
|
-
* @template Type original data type (before transformation)
|
|
300
|
-
* @template Item type of a single item in the data list
|
|
301
|
-
* @template ItemFormatters item type after formatters are applied
|
|
302
|
-
* @template Columns search columns derived from formatting
|
|
303
|
-
*
|
|
304
|
-
* @param propsGet main GET request settings (path, reactivity, skeleton, etc.)
|
|
305
|
-
* @param formattersOptions optional reactive formatting rules
|
|
306
|
-
* @param searchOptions optional client-side search settings
|
|
307
|
-
* @param postRequest optional POST mutation settings
|
|
308
|
-
* @param putRequest optional PUT mutation settings
|
|
309
|
-
* @param deleteRequest optional DELETE mutation settings
|
|
310
|
-
* @param action common callback executed after any successful mutation
|
|
311
|
-
* @param apiInstance API instance for requests (defaults to Api.getItem())
|
|
312
|
-
*
|
|
313
|
-
* @returns reactive API management interface
|
|
314
|
-
*
|
|
315
769
|
* @note This hook is recommended to be used in tandem with `executeUse` for centralized state management.
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
* @remarks
|
|
320
|
-
* Data formatting guidelines for `formattersOptions`:
|
|
321
|
-
* - **Recommended for formatting:** Numbers that represent values (prices, counts), dates, currency, units, and statuses.
|
|
322
|
-
* - **Not recommended for formatting:** Technical identifiers such as ID, UUID, account numbers (if used for logic), types, or internal codes.
|
|
323
|
-
*
|
|
770
|
+
* @remarks Data formatting guidelines for `formattersOptions`:
|
|
771
|
+
* - Recommended for values, dates, currencies.
|
|
772
|
+
* - Not recommended for technical identifiers (IDs, UUIDs).
|
|
324
773
|
* @example
|
|
325
|
-
*
|
|
326
|
-
* const products = useApiManagementRef(
|
|
327
|
-
*
|
|
328
|
-
* path: '/api/v1/products',
|
|
329
|
-
* skeleton: () => Array(5).fill({ id: 0, name: 'Loading...', price: 0 })
|
|
330
|
-
* },
|
|
331
|
-
* {
|
|
332
|
-
* // Formatters for display
|
|
333
|
-
* price: (v) => `${v} USD`,
|
|
334
|
-
* created_at: (v) => new Date(v).toLocaleDateString()
|
|
335
|
-
* },
|
|
336
|
-
* {
|
|
337
|
-
* // Client-side search setup
|
|
338
|
-
* columns: ['name', 'category']
|
|
339
|
-
* },
|
|
340
|
-
* { path: '/api/v1/products' }, // POST (create)
|
|
341
|
-
* { path: (data) => `/api/v1/products/${data.id}` }, // PUT (update)
|
|
342
|
-
* { path: (data) => `/api/v1/products/${data.id}` } // DELETE (remove)
|
|
343
|
-
* );
|
|
344
|
-
*
|
|
345
|
-
* // Accessing data:
|
|
346
|
-
* // products.list.value -> processed, formatted, and searched list
|
|
347
|
-
* // products.sendPost({ name: 'New Product', price: 100 }) -> execute mutation
|
|
774
|
+
* ```typescript
|
|
775
|
+
* const products = useApiManagementRef({ path: '/api/v1/products' });
|
|
776
|
+
* ```
|
|
348
777
|
*/
|
|
349
778
|
export declare function useApiManagementRef<Return extends ApiManagementValue, FormattersOptions extends FormattersOptionsList, Post extends Record<string, any>, Put extends Record<string, any>, Delete extends Record<string, any>, Type extends ApiManagementValue = Return, Item extends ArrayToItem<Return> = ArrayToItem<Return>, ItemFormatters extends FormattersListColumns<Item, FormattersOptions>[number] = FormattersListColumns<Item, FormattersOptions>[number], Columns extends SearchColumns<ItemFormatters> = []>(propsGet: ApiManagementGet<Return, Type>, formattersOptions?: FormattersOptions, searchOptions?: ApiManagementSearch<Item, Columns>, postRequest?: ApiManagementRequest<Post>, putRequest?: ApiManagementRequest<Put>, deleteRequest?: ApiManagementRequest<Delete>, action?: () => Promise<void> | void, apiInstance?: ApiInstance): {
|
|
350
779
|
isValid: ComputedRef<boolean>;
|
|
@@ -372,128 +801,56 @@ export declare function useApiManagementRef<Return extends ApiManagementValue, F
|
|
|
372
801
|
sendPut: (request?: ApiFetch["request"]) => Promise<ApiData<Put> | undefined>;
|
|
373
802
|
sendDelete: (request?: ApiFetch["request"]) => Promise<ApiData<Delete> | undefined>;
|
|
374
803
|
};
|
|
375
|
-
|
|
804
|
+
/** Use API post request helper wrapper. */
|
|
376
805
|
export declare function useApiPost<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiPostSetup<T, Request, Return>): {
|
|
377
806
|
loading: Ref<boolean, boolean>;
|
|
378
807
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
379
808
|
};
|
|
380
|
-
|
|
809
|
+
/** Use API put request helper wrapper. */
|
|
381
810
|
export declare function useApiPut<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>(setup: UseApiPutSetup<T, Request, Return>): {
|
|
382
811
|
loading: Ref<boolean, boolean>;
|
|
383
812
|
send(request?: Request | undefined): Promise<Return | undefined>;
|
|
384
813
|
};
|
|
385
|
-
export interface UseApiRef<R> {
|
|
386
|
-
data: ComputedRef<ApiData<R> | undefined>;
|
|
387
|
-
item: Ref<ApiData<R> | undefined>;
|
|
388
|
-
errorItem: ComputedRef<ApiErrorItem | undefined>;
|
|
389
|
-
isResponseContractValid: ComputedRef<boolean>;
|
|
390
|
-
responseValidationResult: ComputedRef<ApiDataValidation | undefined>;
|
|
391
|
-
length: ComputedRef<number>;
|
|
392
|
-
starting: ComputedRef<boolean>;
|
|
393
|
-
loading: Ref<boolean>;
|
|
394
|
-
reading: Ref<boolean>;
|
|
395
|
-
isStarting(): boolean;
|
|
396
|
-
isLoading(): boolean;
|
|
397
|
-
isReading(): boolean;
|
|
398
|
-
getItem(): ApiData<R> | undefined;
|
|
399
|
-
init(): void;
|
|
400
|
-
initSsr(): void;
|
|
401
|
-
reset(): Promise<void>;
|
|
402
|
-
stop(): void;
|
|
403
|
-
abort(): void;
|
|
404
|
-
}
|
|
405
814
|
/**
|
|
406
815
|
* Main reactive composable for working with API requests in Vue.
|
|
407
|
-
* Automatically handles SSR, reactivity, caching, error storage, data validation, and transformation.
|
|
408
|
-
*
|
|
409
816
|
* @example
|
|
410
817
|
* ```typescript
|
|
411
|
-
*
|
|
412
|
-
* import { useApiRef } from '@dxtmisha/functional'
|
|
413
|
-
*
|
|
414
|
-
* // Define a schema using @effect/schema
|
|
415
|
-
* const userSchema = S.Struct({ id: S.Number, name: S.String })
|
|
416
|
-
*
|
|
417
|
-
* const { data, loading, errorItem, isResponseContractValid } = useApiRef(
|
|
418
|
-
* '/users/1',
|
|
419
|
-
* { method: 'GET' },
|
|
420
|
-
* true, // reactivity
|
|
421
|
-
* undefined, // conditions
|
|
422
|
-
* (data) => ({ ...data, isTransformed: true }), // transformation
|
|
423
|
-
* (data) => { // validateResponseContract
|
|
424
|
-
* try {
|
|
425
|
-
* return { status: 'success', data: S.decodeUnknownSync(userSchema)(data) }
|
|
426
|
-
* } catch (e) {
|
|
427
|
-
* return { status: 'error', errors: e }
|
|
428
|
-
* }
|
|
429
|
-
* },
|
|
430
|
-
* [ // errorContract (ApiErrorStorageList)
|
|
431
|
-
* {
|
|
432
|
-
* status: 404,
|
|
433
|
-
* message: 'User not found'
|
|
434
|
-
* }
|
|
435
|
-
* ]
|
|
436
|
-
* )
|
|
818
|
+
* const { data, loading } = useApiRef('/users/1');
|
|
437
819
|
* ```
|
|
438
|
-
*
|
|
439
|
-
* @param path path to request (can be a Ref or Getter)
|
|
440
|
-
* @param options data for the request (headers, method, etc.)
|
|
441
|
-
* @param reactivity should reactivity be enabled (automatically re-fetch on deps change)
|
|
442
|
-
* @param conditions conditions for executing the request (request will wait until true)
|
|
443
|
-
* @param transformation transforms the received response data
|
|
444
|
-
* @param validateResponseContract function to validate response data contract. Used to ensure that the API
|
|
445
|
-
* response matches the expected structure. Highly recommended to use with `@effect/schema`.
|
|
446
|
-
* It should return `ApiDataValidation` containing a `status` ('success' or 'error')
|
|
447
|
-
* and the parsed data or errors.
|
|
448
|
-
* @param errorContract array of expected error contracts for the request (`ApiErrorStorageList`).
|
|
449
|
-
* Highly recommended to add if there is information about possible request errors. Allows you to predefine
|
|
450
|
-
* possible errors (by code, status, or custom validation). If an error occurs matching one of these contracts,
|
|
451
|
-
* it will be automatically processed and made available via the `errorItem` computed property.
|
|
452
|
-
* @param unmounted whether to stop the request and clear data from cache when component is unmounted
|
|
453
|
-
* @param apiInstance Api instance (defaults to global Api instance)
|
|
454
820
|
*/
|
|
455
821
|
export declare function useApiRef<R, T = R>(path?: RefOrNormal<string | undefined>, options?: ApiOptions, reactivity?: boolean, conditions?: RefType<boolean>, transformation?: (data: T, isResponseContractValid?: ApiDataValidation) => ApiData<R>, validateResponseContract?: (data: T) => ApiDataValidation, errorContract?: ApiErrorStorageList, unmounted?: boolean, apiInstance?: ApiInstance): UseApiRef<R>;
|
|
456
822
|
export declare const setApiRefGlobalConditions: (conditions: RefType<any>) => void;
|
|
457
|
-
|
|
458
|
-
path?: RefOrNormal<string | undefined>;
|
|
459
|
-
method?: ApiMethodItem;
|
|
460
|
-
action?: (data: Return | undefined) => Promise<void> | void;
|
|
461
|
-
transformation?: (data: T) => Return;
|
|
462
|
-
validateRequestContract?: (data: Request) => ApiDataValidation & Return;
|
|
463
|
-
validateResponseContract?: (data: T) => ApiDataValidation & Return;
|
|
464
|
-
errorContract?: ApiErrorStorageList;
|
|
465
|
-
toData?: boolean;
|
|
466
|
-
options?: ApiOptions;
|
|
467
|
-
apiInstance?: ApiInstance;
|
|
468
|
-
}
|
|
823
|
+
/** Sends configured API request. */
|
|
469
824
|
export declare function useApiRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>>({ path, method, action, transformation, validateRequestContract, validateResponseContract, errorContract, toData, options, apiInstance }: UseApiRequestSetup<T, Request, Return>): {
|
|
470
825
|
loading: Ref<boolean, boolean>;
|
|
471
826
|
send(request?: Request): Promise<Return | undefined>;
|
|
472
827
|
};
|
|
828
|
+
/** Creates reactive variable synced across browser tabs using BroadcastChannel. */
|
|
473
829
|
export declare function useBroadcastValueRef<T>(name: string, defaultValue?: T | string | (() => (T | string))): Ref<T | string | undefined>;
|
|
830
|
+
/** Creates reactive cookie reference. */
|
|
474
831
|
export declare function useCookieRef<T>(name: string, defaultValue?: T | string | (() => (T | string)), options?: CookieOptions): Ref<T | string | undefined>;
|
|
832
|
+
/** Composable for reactive formatting of data lists based on rules. */
|
|
475
833
|
export declare function useFormattersRef<Options extends FormattersOptionsList = FormattersOptionsList, List extends FormattersListProp = FormattersListProp>(list: RefType<List | undefined>, options: Options): {
|
|
476
834
|
listFormat: ComputedRef<FormattersReturn<List, Options>>;
|
|
477
835
|
length: ComputedRef<number>;
|
|
478
836
|
};
|
|
837
|
+
/**
|
|
838
|
+
* Returns GeoIntlRef instance.
|
|
839
|
+
* @remarks
|
|
840
|
+
* Avoid using this reactive composable if reactive updates are not required.
|
|
841
|
+
* For non-reactive formatting, use `GeoIntl` directly.
|
|
842
|
+
*/
|
|
479
843
|
export declare function useGeoIntlRef(): GeoIntlRef;
|
|
844
|
+
/** Returns GeoUnitRef instance. */
|
|
480
845
|
export declare function useGeoUnitRef(): GeoUnitRef;
|
|
846
|
+
/** Creates reactive hash variable. */
|
|
481
847
|
export declare function useHashRef<T>(name: string, defaultValue?: T | (() => T)): ShallowRef<T>;
|
|
482
|
-
|
|
483
|
-
rootMargin: string;
|
|
484
|
-
item: ReturnType<typeof useLazyRef>;
|
|
485
|
-
};
|
|
848
|
+
/** Hook for initializing lazy tracking of element appearance with root margin. */
|
|
486
849
|
export declare const useLazyItemByMarginRef: (element: RefType<HTMLElement | undefined>, rootMargin?: string) => {
|
|
487
850
|
lazyItemStatus: ShallowRef<boolean, boolean>;
|
|
488
851
|
readonly lazyItem: LazyItem | undefined;
|
|
489
852
|
};
|
|
490
|
-
|
|
491
|
-
status: ShallowRef<boolean>;
|
|
492
|
-
ratio: ShallowRef<number>;
|
|
493
|
-
entry: ShallowRef<IntersectionObserverEntry | undefined>;
|
|
494
|
-
stopWatch: () => void;
|
|
495
|
-
};
|
|
496
|
-
export type LazyList = Record<string, LazyItem>;
|
|
853
|
+
/** Hook for initializing lazy element appearance tracking. */
|
|
497
854
|
export declare const useLazyRef: (options?: IntersectionObserverInit) => {
|
|
498
855
|
intersectionObserver: IntersectionObserver | undefined;
|
|
499
856
|
getItem(element?: HTMLElement): LazyItem | undefined;
|
|
@@ -501,7 +858,9 @@ export declare const useLazyRef: (options?: IntersectionObserverInit) => {
|
|
|
501
858
|
removeLazyItem: (element?: HTMLElement) => void;
|
|
502
859
|
disconnectLazy: () => void | undefined;
|
|
503
860
|
};
|
|
861
|
+
/** Returns reactive global loading status. */
|
|
504
862
|
export declare function useLoadingRef(): ShallowRef<boolean, boolean>;
|
|
863
|
+
/** Vue composable for reactive meta tags management with DOM synchronization. */
|
|
505
864
|
export declare const useMeta: () => Readonly<{
|
|
506
865
|
meta: Meta;
|
|
507
866
|
title: Ref<string, string>;
|
|
@@ -552,7 +911,9 @@ export declare const useMeta: () => Readonly<{
|
|
|
552
911
|
}>;
|
|
553
912
|
destroyExecute?(): void;
|
|
554
913
|
};
|
|
914
|
+
/** Creates reactive URL query parameter reference. */
|
|
555
915
|
export declare function useQueryRef<T>(name: string, defaultValue?: T | (() => T)): ShallowRef<T>;
|
|
916
|
+
/** Managing router link list. */
|
|
556
917
|
export declare const useRouterList: <T extends ListDataBasic>(list: RefType<ConstrBind<T>[] | undefined>, selected?: Ref<string> | string, hasTo?: boolean) => {
|
|
557
918
|
item: ComputedRef<T | undefined>;
|
|
558
919
|
selected: Ref<string, string>;
|
|
@@ -561,6 +922,7 @@ export declare const useRouterList: <T extends ListDataBasic>(list: RefType<Cons
|
|
|
561
922
|
to: (name?: string) => void;
|
|
562
923
|
toMain(): void;
|
|
563
924
|
};
|
|
925
|
+
/** Composable for search logic with reactive data. */
|
|
564
926
|
export declare function useSearchRef<T extends SearchItem, K extends SearchColumns<T>>(list: SearchListInput<T>, columns?: SearchColumnsInput<T, K>, value?: Ref<string>, options?: SearchOptions): {
|
|
565
927
|
isSearch: ComputedRef<boolean>;
|
|
566
928
|
search: Ref<string, string>;
|
|
@@ -568,153 +930,62 @@ export declare function useSearchRef<T extends SearchItem, K extends SearchColum
|
|
|
568
930
|
listSearch: ComputedRef<SearchFormatList<T, K>>;
|
|
569
931
|
length: ComputedRef<number>;
|
|
570
932
|
};
|
|
933
|
+
/** Composable for search value state and handling delays. */
|
|
571
934
|
export declare function useSearchValueRef<T extends SearchItem, K extends SearchColumns<T>>(item: SearchList<T, K>, value?: Ref<string>): {
|
|
572
935
|
search: Ref<string, string>;
|
|
573
936
|
searchDelay: Ref<string, string>;
|
|
574
937
|
loading: Ref<boolean, boolean>;
|
|
575
938
|
};
|
|
939
|
+
/** Creates reactive session storage reference. */
|
|
576
940
|
export declare function useSessionRef<T>(name: string, defaultValue?: T | (() => T)): Ref<T | undefined>;
|
|
941
|
+
/** Creates reactive local storage reference. */
|
|
577
942
|
export declare function useStorageRef<T>(name: string, defaultValue?: T | (() => T), cache?: number): Ref<T | undefined>;
|
|
578
943
|
/**
|
|
579
|
-
* Getting
|
|
580
|
-
*
|
|
581
|
-
* It returns a `ShallowRef` that automatically updates when the global language changes.
|
|
582
|
-
* Use `as const` for arrays to ensure proper TypeScript key inference.
|
|
583
|
-
*
|
|
584
|
-
* ### Examples:
|
|
944
|
+
* Getting translated text by keys.
|
|
945
|
+
* @example
|
|
585
946
|
* ```typescript
|
|
586
|
-
*
|
|
587
|
-
* const translations = useTranslateRef(['home.title', 'home.description'] as const);
|
|
588
|
-
*
|
|
589
|
-
* // 2. Using the shorthand 't'
|
|
590
|
-
* const labels = t(['button.save', 'button.cancel'] as const);
|
|
947
|
+
* const labels = useTranslateRef(['home.title'] as const);
|
|
591
948
|
* ```
|
|
592
|
-
*
|
|
593
|
-
* @param names a string or an array with keys
|
|
594
|
-
* @param translateInstance a translate instance
|
|
595
949
|
*/
|
|
596
950
|
export declare function useTranslateRef<T extends (string | string[])[]>(names: T, translateInstance?: TranslateInstance): ShallowRef<TranslateList<T>>;
|
|
597
|
-
/**
|
|
598
|
-
* Shorthand for useTranslateRef.
|
|
599
|
-
* Use `as const` for arrays to ensure proper TypeScript key inference.
|
|
600
|
-
*
|
|
601
|
-
* @param names a string or an array with keys
|
|
602
|
-
*/
|
|
951
|
+
/** Shorthand for useTranslateRef. */
|
|
603
952
|
export declare const t: <T extends string[]>(names: T) => ShallowRef<TranslateList<T>>;
|
|
604
|
-
|
|
953
|
+
/** Creates computed property handling async getters. */
|
|
605
954
|
export declare function computedAsync<R>(getter: (() => Promise<R>) | (() => R) | R, initialState?: (() => R) | R, ignore?: R, debugOptions?: DebuggerOptions): ComputedRef<R | undefined>;
|
|
955
|
+
/** Creates computed property dependent on current language state. */
|
|
606
956
|
export declare function computedByLanguage<T, R extends (T | undefined) = T | undefined>(getter: ComputedGetter<R>, getterNone?: R | (() => R), conditions?: () => boolean, debugOptions?: DebuggerOptions): ComputedRef<R>;
|
|
957
|
+
/** Creates cached computed property computed on demand. */
|
|
607
958
|
export declare function computedEternity<T>(getter: () => Promise<T> | T, initialState?: (() => T) | T): Ref<T, T>;
|
|
608
|
-
export interface FunctionalPluginOptions {
|
|
609
|
-
api?: ApiConfig;
|
|
610
|
-
translate?: TranslateConfig;
|
|
611
|
-
location?: string | (() => string);
|
|
612
|
-
metaSuffix?: string;
|
|
613
|
-
icons?: IconsConfig;
|
|
614
|
-
iconsSocial?: InputSocialIcons;
|
|
615
|
-
router?: Router;
|
|
616
|
-
errorCauses?: ErrorCenterCauseList;
|
|
617
|
-
errorHandlers?: ErrorCenterHandlerList;
|
|
618
|
-
errorCallbacks?: ErrorCenterHandlerCallback[];
|
|
619
|
-
}
|
|
620
959
|
/**
|
|
621
|
-
* Vue plugin for initializing
|
|
622
|
-
* (Api, Translate, Icons, Meta).
|
|
623
|
-
*
|
|
960
|
+
* Vue plugin for initializing global functional services.
|
|
624
961
|
* @example
|
|
625
962
|
* ```typescript
|
|
626
|
-
*
|
|
627
|
-
* import { dxtFunctionalPlugin } from '@dxtmisha/functional'
|
|
628
|
-
* import router from './router'
|
|
629
|
-
*
|
|
630
|
-
* const app = createApp(App)
|
|
631
|
-
* app.use(dxtFunctionalPlugin, {
|
|
632
|
-
* api: { url: 'https://api.example.com' },
|
|
633
|
-
* metaSuffix: ' | My App',
|
|
634
|
-
* router
|
|
635
|
-
* })
|
|
963
|
+
* app.use(dxtFunctionalPlugin, { api: { url: 'https://api.example.com' } });
|
|
636
964
|
* ```
|
|
637
965
|
*/
|
|
638
966
|
export declare const dxtFunctionalPlugin: Plugin;
|
|
967
|
+
/** Types of initialization for executeUse singleton. */
|
|
639
968
|
export declare enum ExecuteUseType {
|
|
640
969
|
global = "global",
|
|
641
970
|
provide = "provide",
|
|
642
971
|
local = "local"
|
|
643
972
|
}
|
|
973
|
+
/** Return structure of executeUse singleton wrapper. */
|
|
644
974
|
export type ExecuteUseReturn<R> = Readonly<R & {
|
|
645
975
|
init(): Readonly<R>;
|
|
646
976
|
destroyExecute?(): void;
|
|
647
977
|
}>;
|
|
648
978
|
/**
|
|
649
|
-
* Creates
|
|
650
|
-
*
|
|
651
|
-
* It supports three initialization strategies:
|
|
652
|
-
* - `global`: A single instance for the entire application.
|
|
653
|
-
* - `provide`: Shared via provide/inject in the component tree (standard for Vue 3).
|
|
654
|
-
* - `local`: A single instance within the closure of the returned function.
|
|
655
|
-
*
|
|
656
|
-
* @template R return type of the factory function
|
|
657
|
-
* @template O argument types for the factory function
|
|
658
|
-
* @template RI instance type with management methods
|
|
659
|
-
*
|
|
660
|
-
* @param callback initialization function
|
|
661
|
-
* @param type initialization strategy (defaults to provide)
|
|
662
|
-
*
|
|
663
|
-
* @returns {function} accessor function for the singleton
|
|
664
|
-
*
|
|
979
|
+
* Creates managed singleton encapsulating initialization strategy.
|
|
665
980
|
* @remarks
|
|
666
|
-
* Use
|
|
667
|
-
* - **API Services:** Always wrap API clients to ensure a single connection point and unified state.
|
|
668
|
-
* - **Resource Optimization:** For functions where creating multiple instances is undesirable (e.g., heavy objects, event buses).
|
|
669
|
-
* - **Shared State:** To share reactive state within a component tree using the `provide` strategy.
|
|
670
|
-
* - **External SDKs:** Initializing third-party libraries (analytics, maps, charts) that should be singletons.
|
|
671
|
-
*
|
|
672
|
-
* @example
|
|
673
|
-
* // 1. Global API singleton (useApiGet)
|
|
674
|
-
* export const useUserApi = executeUseGlobal(() => {
|
|
675
|
-
* return useApiGet('/api/user');
|
|
676
|
-
* });
|
|
677
|
-
*
|
|
678
|
-
* @example
|
|
679
|
-
* // 2. Shared Reactive State
|
|
680
|
-
* export const useFeatureState = executeUseProvide(() => {
|
|
681
|
-
* // Reactive logic here
|
|
682
|
-
* const items = [];
|
|
683
|
-
* const addItem = (item) => items.push(item);
|
|
684
|
-
* return { items, addItem };
|
|
685
|
-
* });
|
|
686
|
-
*
|
|
981
|
+
* Use for API services, resource optimization, and shared state.
|
|
687
982
|
* @example
|
|
688
|
-
*
|
|
689
|
-
* export const
|
|
690
|
-
*
|
|
691
|
-
* });
|
|
692
|
-
*
|
|
693
|
-
* @example
|
|
694
|
-
* // 4. Complex API Service (useApiManagementRef)
|
|
695
|
-
* export const useUserManagement = executeUseGlobal(() => {
|
|
696
|
-
* return useApiManagementRef(
|
|
697
|
-
* { path: '/api/users' }, // GET setup
|
|
698
|
-
* { date: (v) => new Date(v).toLocaleString() }, // Formatters
|
|
699
|
-
* { columns: ['name', 'email'] }, // Search
|
|
700
|
-
* { path: '/api/users' }, // POST (create)
|
|
701
|
-
* { path: (o) => `/api/users/${o.id}` }, // PUT (update)
|
|
702
|
-
* { path: (o) => `/api/users/${o.id}` } // DELETE (remove)
|
|
703
|
-
* );
|
|
704
|
-
* });
|
|
705
|
-
*
|
|
706
|
-
* // Usage in component:
|
|
707
|
-
* // const { list, loading, sendPost, sendDelete } = useUserManagement();
|
|
983
|
+
* ```typescript
|
|
984
|
+
* export const useUserApi = executeUseGlobal(() => useApiGet('/api/user'));
|
|
985
|
+
* ```
|
|
708
986
|
*/
|
|
709
987
|
export declare function executeUse<R, O extends any[], RI extends ExecuteUseReturn<R> = ExecuteUseReturn<R>>(callback: (...args: O) => R, type?: ExecuteUseType): ((...args: O) => RI) | (() => RI);
|
|
710
|
-
/**
|
|
711
|
-
* Creates a global singleton.
|
|
712
|
-
*
|
|
713
|
-
* @remarks
|
|
714
|
-
* See {@link executeUse} for more details.
|
|
715
|
-
*
|
|
716
|
-
* @param callback Initialization function
|
|
717
|
-
*/
|
|
988
|
+
/** Creates global singleton. */
|
|
718
989
|
export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<R & {
|
|
719
990
|
init(): Readonly<R>;
|
|
720
991
|
destroyExecute?(): void;
|
|
@@ -722,15 +993,7 @@ export declare function executeUseGlobal<R>(callback: () => R): (() => Readonly<
|
|
|
722
993
|
init(): Readonly<R>;
|
|
723
994
|
destroyExecute?(): void;
|
|
724
995
|
}>);
|
|
725
|
-
/**
|
|
726
|
-
* Creates a component-scoped singleton.
|
|
727
|
-
*
|
|
728
|
-
* @remarks
|
|
729
|
-
* Best for sharing state within a component sub-tree.
|
|
730
|
-
* See {@link executeUse} for more details.
|
|
731
|
-
*
|
|
732
|
-
* @param callback Initialization function
|
|
733
|
-
*/
|
|
996
|
+
/** Creates component-scoped singleton via provide/inject. */
|
|
734
997
|
export declare function executeUseProvide<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
|
|
735
998
|
init(): Readonly<R>;
|
|
736
999
|
destroyExecute?(): void;
|
|
@@ -738,15 +1001,7 @@ export declare function executeUseProvide<R, O extends any[]>(callback: (...args
|
|
|
738
1001
|
init(): Readonly<R>;
|
|
739
1002
|
destroyExecute?(): void;
|
|
740
1003
|
}>);
|
|
741
|
-
/**
|
|
742
|
-
* Creates a local singleton.
|
|
743
|
-
*
|
|
744
|
-
* @remarks
|
|
745
|
-
* Best for internal state preservation within a closure.
|
|
746
|
-
* See {@link executeUse} for more details.
|
|
747
|
-
*
|
|
748
|
-
* @param callback Initialization function
|
|
749
|
-
*/
|
|
1004
|
+
/** Creates local singleton inside closure. */
|
|
750
1005
|
export declare function executeUseLocal<R, O extends any[]>(callback: (...args: O) => R): ((...args: O) => Readonly<R & {
|
|
751
1006
|
init(): Readonly<R>;
|
|
752
1007
|
destroyExecute?(): void;
|
|
@@ -754,146 +1009,33 @@ export declare function executeUseLocal<R, O extends any[]>(callback: (...args:
|
|
|
754
1009
|
init(): Readonly<R>;
|
|
755
1010
|
destroyExecute?(): void;
|
|
756
1011
|
}>);
|
|
1012
|
+
/** Initializes all registered global singletons. */
|
|
757
1013
|
export declare function executeUseGlobalInit(): void;
|
|
1014
|
+
/** Gets injected Vue value by key name. */
|
|
758
1015
|
export declare function getInject<T>(name: string): T | undefined;
|
|
1016
|
+
/** Resolves options object for API fetch calls. */
|
|
759
1017
|
export declare const getOptions: (options?: ApiOptions) => RefOrNormal<ApiFetch>;
|
|
1018
|
+
/** Executes argument if function and unwraps resulting Vue ref. */
|
|
760
1019
|
export declare function executeFunctionRef<T>(data: RefOrNormalOrFunction<T>): T;
|
|
1020
|
+
/** Returns reactive error item from API ref data. */
|
|
761
1021
|
export declare function getApiErrorRef<R>(data: RefType<ApiData<R> | undefined>): ComputedRef<ApiErrorItem | undefined>;
|
|
1022
|
+
/** Generates computed properties binding for subcomponent. */
|
|
762
1023
|
export declare function getBindRef<T, R extends ItemList>(value: RefOrNormal<T | R> | undefined, nameExtra?: RefOrNormal<ItemList> | string, name?: string): ComputedRef<R>;
|
|
1024
|
+
/** Unwraps ref value or returns raw value. */
|
|
763
1025
|
export declare function getRef<T>(item: RefOrNormal<T>): T;
|
|
1026
|
+
/** Renders component VNode with cached properties. */
|
|
764
1027
|
export declare function render<T extends ItemList>(name: string | any, props?: T, children?: RawChildren | RawSlots, index?: string): VNode;
|
|
1028
|
+
/** Updates ref value if changed. */
|
|
765
1029
|
export declare function setRef<T>(item: Ref<T>, value: T): void;
|
|
1030
|
+
/** Wraps value into Vue ref if not reactive. */
|
|
766
1031
|
export declare function toRefItem<T>(item: RefOrNormal<T>): Ref<T>;
|
|
1032
|
+
/** Merges two property objects merging classes and styles. */
|
|
767
1033
|
export declare function getBind<T, R extends ItemList>(value: T | R | undefined | null, nameExtra?: ItemList | string, name?: string, except?: boolean): ConstrBind<R>;
|
|
1034
|
+
/** Returns class name property from component props object. */
|
|
768
1035
|
export declare function getClassName<T extends ItemList>(props?: T): string | undefined;
|
|
1036
|
+
/** Returns or generates index key for VNode rendering. */
|
|
769
1037
|
export declare function getIndexForRender<T extends ItemList>(name: string | any, props?: T, index?: string): string | undefined;
|
|
1038
|
+
/** Merges two objects taking into account class and style arrays. */
|
|
770
1039
|
export declare function toBind<R extends ItemList = ItemList>(extra: ItemList, value: ItemList): ConstrBind<R>;
|
|
771
|
-
|
|
772
|
-
export
|
|
773
|
-
export type ApiManagementValue = ApiDefaultValue | ApiDefaultValue[];
|
|
774
|
-
export type ApiManagementGet<Return extends ApiManagementValue, Type extends ApiManagementValue = Return> = {
|
|
775
|
-
path?: RefOrNormal<string | undefined>;
|
|
776
|
-
options?: ApiOptions;
|
|
777
|
-
reactivity?: boolean;
|
|
778
|
-
conditions?: RefType<boolean>;
|
|
779
|
-
transformation?: (data: Type, isResponseContractValid?: ApiDataValidation) => ApiData<Return>;
|
|
780
|
-
validateResponseContract?: (data: Type) => ApiDataValidation;
|
|
781
|
-
errorContract?: ApiErrorStorageList;
|
|
782
|
-
typeData?: ((data: Return) => boolean) | any;
|
|
783
|
-
unmounted?: boolean;
|
|
784
|
-
skeleton?: () => Return;
|
|
785
|
-
};
|
|
786
|
-
export type ApiManagementSearch<T extends SearchItem, K extends SearchColumns<T>> = {
|
|
787
|
-
columns: K;
|
|
788
|
-
value?: Ref<string>;
|
|
789
|
-
options?: SearchOptions;
|
|
790
|
-
};
|
|
791
|
-
export type ApiManagementRequest<T, Request extends ApiFetch['request'] = ApiFetch['request'], Return extends ApiData<T> = ApiData<T>> = {
|
|
792
|
-
path?: RefOrNormal<string | undefined>;
|
|
793
|
-
action?: (data: Return | undefined) => Promise<void> | void;
|
|
794
|
-
transformation?: (data: T) => Return;
|
|
795
|
-
validateRequestContract?: (data: Request) => ApiDataValidation & Return;
|
|
796
|
-
validateResponseContract?: (data: T) => ApiDataValidation & Return;
|
|
797
|
-
errorContract?: ApiErrorStorageList;
|
|
798
|
-
toData?: boolean;
|
|
799
|
-
options?: ApiOptions;
|
|
800
|
-
};
|
|
801
|
-
export type ConstrItem = Record<string, any>;
|
|
802
|
-
export type ConstrValue<T = any> = {
|
|
803
|
-
value?: T;
|
|
804
|
-
};
|
|
805
|
-
export type ConstrComponent = Record<string, any>;
|
|
806
|
-
export type ConstrComponentMod<P extends ConstrItem> = ConstrItem | {
|
|
807
|
-
[K in keyof P]?: RefOrNormal<P[K]>;
|
|
808
|
-
};
|
|
809
|
-
export type ConstrExpose<E extends Element, EXPOSE extends ConstrItem> = EXPOSE & {
|
|
810
|
-
elementHtml?: ComputedRef<E | undefined>;
|
|
811
|
-
};
|
|
812
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
813
|
-
export type ConstrEmitItem<T extends ConstrItem> = T[keyof T];
|
|
814
|
-
export type ConstrEmit<T extends ConstrItem = ConstrItem> = UnionToIntersection<ConstrEmitItem<{
|
|
815
|
-
[K in keyof T]: (evt: K, ...args: T[K]) => void;
|
|
816
|
-
}>>;
|
|
817
|
-
export type ConstrClassObject = Record<string, boolean | undefined>;
|
|
818
|
-
export type ConstrClass = string | (string | ConstrClass | Undefined)[] | ConstrClassObject;
|
|
819
|
-
export type ConstrClassList = Record<string, ConstrClass>;
|
|
820
|
-
export type ConstrClasses = {
|
|
821
|
-
main: ConstrClass;
|
|
822
|
-
} & ConstrClassList;
|
|
823
|
-
export type ConstrStylesItem = string | null;
|
|
824
|
-
export type ConstrStyles = Record<string, ConstrStylesItem> | ConstrStyles[];
|
|
825
|
-
export type ConstrOptions<COMP extends ConstrComponent, EMITS extends ConstrItem, P extends ConstrItem> = {
|
|
826
|
-
components?: COMP;
|
|
827
|
-
compMod?: ConstrComponentMod<P>;
|
|
828
|
-
emits?: ConstrEmit<EMITS>;
|
|
829
|
-
classes?: RefType<ConstrClasses>;
|
|
830
|
-
styles?: RefType<ConstrStyles>;
|
|
831
|
-
};
|
|
832
|
-
export type ConstrSetup<E extends Element, CLASSES extends ConstrClasses, SETUP extends ConstrItem> = {
|
|
833
|
-
name: string;
|
|
834
|
-
element: Ref<E | undefined>;
|
|
835
|
-
classes: RefType<CLASSES>;
|
|
836
|
-
styles: RefType<ConstrStyles>;
|
|
837
|
-
} & SETUP;
|
|
838
|
-
export type ConstrRegistration = {
|
|
839
|
-
flag?: boolean;
|
|
840
|
-
translate?: Record<string, string>;
|
|
841
|
-
};
|
|
842
|
-
export type ConstrBind<T> = T & Record<string, any> & {
|
|
843
|
-
key?: string;
|
|
844
|
-
class?: ConstrClass;
|
|
845
|
-
style?: ConstrStyles;
|
|
846
|
-
};
|
|
847
|
-
export type ConstrPropItemOptions<T = any> = {
|
|
848
|
-
type?: PropType<T>;
|
|
849
|
-
required?: boolean;
|
|
850
|
-
default?: any;
|
|
851
|
-
validator?(value: any, props: any): boolean;
|
|
852
|
-
};
|
|
853
|
-
export type ConstrPropItem<T = any> = ConstrPropItemOptions<T> | PropType<T>;
|
|
854
|
-
export type ConstrProps<P = Record<string, any>> = {
|
|
855
|
-
[K in keyof P]: ConstrPropItem<P[K]>;
|
|
856
|
-
};
|
|
857
|
-
export type ConstrHrefProps = {
|
|
858
|
-
href?: string;
|
|
859
|
-
};
|
|
860
|
-
export type ListType = 'item' | 'space' | 'line' | 'subtitle' | 'html' | 'menu' | 'menu-group' | 'group';
|
|
861
|
-
export type ListDataBasic = {
|
|
862
|
-
label?: NumberOrString;
|
|
863
|
-
value?: any;
|
|
864
|
-
search?: string;
|
|
865
|
-
};
|
|
866
|
-
export type ListDataItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item & {
|
|
867
|
-
parent?: string;
|
|
868
|
-
type: ListType;
|
|
869
|
-
index: string;
|
|
870
|
-
disabled?: boolean;
|
|
871
|
-
}>;
|
|
872
|
-
export type ListList<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item>[];
|
|
873
|
-
export type ListRecord<Item extends ListDataBasic = ListDataBasic> = ListList<Item> | Record<string, any>;
|
|
874
|
-
export type ListDataFullItem<Item extends ListDataBasic = ListDataBasic> = ListDataItem<Item> & {
|
|
875
|
-
focus: boolean;
|
|
876
|
-
highlight?: string;
|
|
877
|
-
selected: boolean;
|
|
878
|
-
disabled?: boolean;
|
|
879
|
-
};
|
|
880
|
-
export type ListDataFull<Item extends ListDataBasic = ListDataBasic> = ListDataFullItem<Item>[];
|
|
881
|
-
export type ListListInputItem<Item extends ListDataBasic = ListDataBasic> = ConstrBind<Item>;
|
|
882
|
-
export type ListListInput<Item extends ListDataBasic = ListDataBasic> = ListListInputItem<Item>[] | string[] | Record<string, ListListInputItem<Item>> | Record<string, string>;
|
|
883
|
-
export type ListSelectedItem = NumberOrStringOrBoolean;
|
|
884
|
-
export type ListSelectedList = ListSelectedItem | ListSelectedItem[];
|
|
885
|
-
export type ListName = string | number | undefined;
|
|
886
|
-
export type ListNames = ListName[];
|
|
887
|
-
export type RefType<T> = ComputedRef<T> | Ref<T>;
|
|
888
|
-
export type RefUndefined<T> = RefType<T | undefined>;
|
|
889
|
-
export type RefOrNormal<T> = RefType<T> | T;
|
|
890
|
-
export type RefOrNormalOrFunction<T> = RefOrNormal<T> | (() => RefOrNormal<T>);
|
|
891
|
-
export type RawChildren = string | number | boolean | VNode | VNodeArrayChildren | (() => any);
|
|
892
|
-
export type RawSlots = {
|
|
893
|
-
[name: string]: unknown;
|
|
894
|
-
$stable?: boolean;
|
|
895
|
-
};
|
|
896
|
-
export type SearchListValueRef<T extends SearchItem> = RefOrNormal<SearchListValue<T>>;
|
|
897
|
-
export type SearchListInput<T extends SearchItem> = SearchListValueRef<T> | (() => SearchListValueRef<T>);
|
|
898
|
-
export type SearchColumnsRef<T extends SearchItem, K extends SearchColumns<T>> = RefOrNormal<K>;
|
|
899
|
-
export type SearchColumnsInput<T extends SearchItem, K extends SearchColumns<T>> = SearchColumnsRef<T, K> | (() => SearchColumnsRef<T, K>);
|
|
1040
|
+
/** Merges multiple property objects preserving classes and styles. */
|
|
1041
|
+
export declare function toBinds<R extends ItemList = ItemList>(...values: (ItemList | undefined)[]): ConstrBind<R>;
|