@hybridly/vue 0.0.1-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +805 -0
- package/dist/index.d.ts +555 -0
- package/dist/index.mjs +782 -0
- package/package.json +62 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import * as vue from 'vue';
|
|
2
|
+
import { Plugin as Plugin$2, h, PropType, ComputedRef, ComponentOptions } from 'vue';
|
|
3
|
+
import * as _hybridly_core from '@hybridly/core';
|
|
4
|
+
import { VisitPayload as VisitPayload$1, ResolveComponent as ResolveComponent$1, RouterContextOptions, Plugin as Plugin$1, RouterContext, Method as Method$1, VisitOptions as VisitOptions$1, UrlResolvable as UrlResolvable$1 } from '@hybridly/core';
|
|
5
|
+
export { router } from '@hybridly/core';
|
|
6
|
+
import { ProgressOptions } from '@hybridly/progress-plugin';
|
|
7
|
+
import * as _vue_shared from '@vue/shared';
|
|
8
|
+
import { RequestData } from '@hybridly/utils';
|
|
9
|
+
import { AxiosResponse, AxiosProgressEvent } from 'axios';
|
|
10
|
+
|
|
11
|
+
declare function initializeHybridly(options: HybridlyOptions): Promise<void>;
|
|
12
|
+
interface HybridlyOptions {
|
|
13
|
+
/** ID of the app element. */
|
|
14
|
+
id?: string;
|
|
15
|
+
/** Initial view data. */
|
|
16
|
+
payload?: VisitPayload$1;
|
|
17
|
+
/** A collection of pages. */
|
|
18
|
+
pages?: Record<string, any>;
|
|
19
|
+
/** An optional default persistent layout. */
|
|
20
|
+
layout?: any;
|
|
21
|
+
/** A custom component resolution option. */
|
|
22
|
+
resolve?: ResolveComponent$1;
|
|
23
|
+
/** Custom history state serialization functions. */
|
|
24
|
+
serializer?: RouterContextOptions['serializer'];
|
|
25
|
+
/** Clean up the host element's payload dataset after loading. */
|
|
26
|
+
cleanup?: boolean;
|
|
27
|
+
/** Progressbar options. */
|
|
28
|
+
progress?: boolean | Partial<ProgressOptions>;
|
|
29
|
+
/** Sets up the hybridly router. */
|
|
30
|
+
setup: (options: SetupArguments) => any;
|
|
31
|
+
/** List of Hybridly plugins. */
|
|
32
|
+
plugins?: Plugin$1[];
|
|
33
|
+
}
|
|
34
|
+
interface SetupArguments {
|
|
35
|
+
/** DOM element to mount Vue on. */
|
|
36
|
+
element: Element;
|
|
37
|
+
/** Hybridly wrapper component. */
|
|
38
|
+
wrapper: any;
|
|
39
|
+
/** Hybridly wrapper component properties. */
|
|
40
|
+
props: {
|
|
41
|
+
context: RouterContext;
|
|
42
|
+
};
|
|
43
|
+
/** Vue plugin that registers the devtools. */
|
|
44
|
+
hybridly: Plugin$2;
|
|
45
|
+
/** Renders the wrapper. */
|
|
46
|
+
render: () => ReturnType<typeof h>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare const RouterLink: vue.DefineComponent<{
|
|
50
|
+
href: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
required: true;
|
|
53
|
+
};
|
|
54
|
+
as: {
|
|
55
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
56
|
+
default: string;
|
|
57
|
+
};
|
|
58
|
+
method: {
|
|
59
|
+
type: PropType<Method$1>;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
data: {
|
|
63
|
+
type: PropType<RequestData>;
|
|
64
|
+
default: () => {};
|
|
65
|
+
};
|
|
66
|
+
external: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
default: boolean;
|
|
69
|
+
};
|
|
70
|
+
disabled: {
|
|
71
|
+
type: BooleanConstructor;
|
|
72
|
+
default: boolean;
|
|
73
|
+
};
|
|
74
|
+
options: {
|
|
75
|
+
type: PropType<Omit<VisitOptions$1, "url" | "data" | "method">>;
|
|
76
|
+
default: () => {};
|
|
77
|
+
};
|
|
78
|
+
}, (props: Readonly<_vue_shared.LooseRequired<Readonly<vue.ExtractPropTypes<{
|
|
79
|
+
href: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
required: true;
|
|
82
|
+
};
|
|
83
|
+
as: {
|
|
84
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
85
|
+
default: string;
|
|
86
|
+
};
|
|
87
|
+
method: {
|
|
88
|
+
type: PropType<Method$1>;
|
|
89
|
+
default: string;
|
|
90
|
+
};
|
|
91
|
+
data: {
|
|
92
|
+
type: PropType<RequestData>;
|
|
93
|
+
default: () => {};
|
|
94
|
+
};
|
|
95
|
+
external: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
disabled: {
|
|
100
|
+
type: BooleanConstructor;
|
|
101
|
+
default: boolean;
|
|
102
|
+
};
|
|
103
|
+
options: {
|
|
104
|
+
type: PropType<Omit<VisitOptions$1, "url" | "data" | "method">>;
|
|
105
|
+
default: () => {};
|
|
106
|
+
};
|
|
107
|
+
}>> & {}>>) => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
}>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
|
|
110
|
+
href: {
|
|
111
|
+
type: StringConstructor;
|
|
112
|
+
required: true;
|
|
113
|
+
};
|
|
114
|
+
as: {
|
|
115
|
+
type: (StringConstructor | ObjectConstructor)[];
|
|
116
|
+
default: string;
|
|
117
|
+
};
|
|
118
|
+
method: {
|
|
119
|
+
type: PropType<Method$1>;
|
|
120
|
+
default: string;
|
|
121
|
+
};
|
|
122
|
+
data: {
|
|
123
|
+
type: PropType<RequestData>;
|
|
124
|
+
default: () => {};
|
|
125
|
+
};
|
|
126
|
+
external: {
|
|
127
|
+
type: BooleanConstructor;
|
|
128
|
+
default: boolean;
|
|
129
|
+
};
|
|
130
|
+
disabled: {
|
|
131
|
+
type: BooleanConstructor;
|
|
132
|
+
default: boolean;
|
|
133
|
+
};
|
|
134
|
+
options: {
|
|
135
|
+
type: PropType<Omit<VisitOptions$1, "url" | "data" | "method">>;
|
|
136
|
+
default: () => {};
|
|
137
|
+
};
|
|
138
|
+
}>>, {
|
|
139
|
+
data: RequestData;
|
|
140
|
+
method: Method$1;
|
|
141
|
+
options: Omit<VisitOptions$1, "url" | "data" | "method">;
|
|
142
|
+
as: string | Record<string, any>;
|
|
143
|
+
external: boolean;
|
|
144
|
+
disabled: boolean;
|
|
145
|
+
}>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Preset for `unplugin-auto-imports`.
|
|
149
|
+
* @see https://github.com/antfu/unplugin-auto-imports
|
|
150
|
+
*/
|
|
151
|
+
declare const HybridlyImports: {
|
|
152
|
+
'hybridly/vue': string[];
|
|
153
|
+
hybridly: string[];
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Resolver for `unplugin-vue-components`.
|
|
158
|
+
* @see https://github.com/antfu/unplugin-vue-components
|
|
159
|
+
*/
|
|
160
|
+
declare function HybridlyResolver(options?: AutoImportResolverOptions): {
|
|
161
|
+
type: "component";
|
|
162
|
+
resolve: (name: string) => {
|
|
163
|
+
name: string;
|
|
164
|
+
as: string;
|
|
165
|
+
from: string;
|
|
166
|
+
} | undefined;
|
|
167
|
+
};
|
|
168
|
+
interface AutoImportResolverOptions {
|
|
169
|
+
/**
|
|
170
|
+
* Custom name for the link component.
|
|
171
|
+
*/
|
|
172
|
+
linkName?: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Accesses all current properties. */
|
|
176
|
+
declare function useProperties<T extends object, Global extends GlobalHybridlyProperties>(): vue.DeepReadonly<vue.UnwrapNestedRefs<T & Global>>;
|
|
177
|
+
/** Accesses a property with a dot notation. */
|
|
178
|
+
declare function useProperty<T = GlobalHybridlyProperties, P extends Path<T> = Path<T>, Fallback extends PathValue<T, P> = PathValue<T, P>>(path: [P] extends [never] ? string : P, fallback?: Fallback): ComputedRef<[PathValue<T, P>] extends [never] ? Fallback : PathValue<T, P>>;
|
|
179
|
+
declare type PathImpl<T, K extends keyof T> = K extends string ? T[K] extends Record<string, any> ? T[K] extends ArrayLike<any> ? K | `${K}.${PathImpl<T[K], Exclude<keyof T[K], keyof any[]>>}` : K | `${K}.${PathImpl<T[K], keyof T[K]>}` : K : never;
|
|
180
|
+
declare type Path<T> = PathImpl<T, keyof T> | keyof T;
|
|
181
|
+
declare type PathValue<T, P extends Path<T>> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? Rest extends Path<T[K]> ? PathValue<T[K], Rest> : never : never : P extends keyof T ? T[P] : never;
|
|
182
|
+
|
|
183
|
+
declare type MaybePromise<T> = T | Promise<T>;
|
|
184
|
+
|
|
185
|
+
interface Hooks {
|
|
186
|
+
/**
|
|
187
|
+
* Called before anything when a visit is going to happen.
|
|
188
|
+
*/
|
|
189
|
+
before: (options: VisitOptions) => MaybePromise<any | boolean>;
|
|
190
|
+
/**
|
|
191
|
+
* Called before the request of a visit is going to happen.
|
|
192
|
+
*/
|
|
193
|
+
start: (context: InternalRouterContext) => MaybePromise<any>;
|
|
194
|
+
/**
|
|
195
|
+
* Called when progress on the request is being made.
|
|
196
|
+
*/
|
|
197
|
+
progress: (progress: Progress) => MaybePromise<any>;
|
|
198
|
+
/**
|
|
199
|
+
* Called when data is received after a request for a visit.
|
|
200
|
+
*/
|
|
201
|
+
data: (response: AxiosResponse) => MaybePromise<any>;
|
|
202
|
+
/**
|
|
203
|
+
* Called when a request is successful and there is no error.
|
|
204
|
+
*/
|
|
205
|
+
success: (payload: VisitPayload) => MaybePromise<any>;
|
|
206
|
+
/**
|
|
207
|
+
* Called when a request is successful but there were errors.
|
|
208
|
+
*/
|
|
209
|
+
error: (errors: Errors) => MaybePromise<any>;
|
|
210
|
+
/**
|
|
211
|
+
* Called when a request has been aborted.
|
|
212
|
+
*/
|
|
213
|
+
abort: (context: InternalRouterContext) => MaybePromise<any>;
|
|
214
|
+
/**
|
|
215
|
+
* Called when a response to a request is not a valid Hybridly response.
|
|
216
|
+
*/
|
|
217
|
+
invalid: (response: AxiosResponse) => MaybePromise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Called when an unknowne exception was triggered.
|
|
220
|
+
*/
|
|
221
|
+
exception: (error: Error) => MaybePromise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Called whenever the request failed, for any reason, in addition to other hooks.
|
|
224
|
+
*/
|
|
225
|
+
fail: (context: InternalRouterContext) => MaybePromise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Called after a request has been made, even if it didn't succeed.
|
|
228
|
+
*/
|
|
229
|
+
after: (context: InternalRouterContext) => MaybePromise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Called when a visit has been made and a page component has been navigated to.
|
|
232
|
+
*/
|
|
233
|
+
navigate: (options: NavigationOptions) => MaybePromise<void>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
declare type UrlResolvable = string | URL | Location;
|
|
237
|
+
declare type UrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toString'>>;
|
|
238
|
+
|
|
239
|
+
declare type ConditionalNavigationOption = boolean | ((payload: VisitPayload) => boolean);
|
|
240
|
+
interface NavigationOptions {
|
|
241
|
+
/** View to navigate to. */
|
|
242
|
+
payload?: VisitPayload;
|
|
243
|
+
/**
|
|
244
|
+
* Whether to replace the current history state instead of adding
|
|
245
|
+
* one. This affects the browser's "back" and "forward" features.
|
|
246
|
+
*/
|
|
247
|
+
replace?: ConditionalNavigationOption;
|
|
248
|
+
/** Whether to preserve the current scrollbar position. */
|
|
249
|
+
preserveScroll?: ConditionalNavigationOption;
|
|
250
|
+
/** Whether to preserve the current page component's state. */
|
|
251
|
+
preserveState?: ConditionalNavigationOption;
|
|
252
|
+
/** Whether to preserve the current URL. */
|
|
253
|
+
preserveUrl?: ConditionalNavigationOption;
|
|
254
|
+
/**
|
|
255
|
+
* Properties of the given URL to override.
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* router.get('/login?redirect=/', {
|
|
259
|
+
* transformUrl: { search: '' }
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
transformUrl?: UrlTransformable;
|
|
264
|
+
/**
|
|
265
|
+
* Defines whether the history state should be updated.
|
|
266
|
+
* @internal This is an advanced property meant to be used internally.
|
|
267
|
+
*/
|
|
268
|
+
updateHistoryState?: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Defines whether this navigation is a back/forward visit from the popstate event.
|
|
271
|
+
* @internal This is an advanced property meant to be used internally.
|
|
272
|
+
*/
|
|
273
|
+
isBackForward?: boolean;
|
|
274
|
+
}
|
|
275
|
+
declare type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
276
|
+
interface VisitOptions extends Omit<NavigationOptions, 'request'> {
|
|
277
|
+
/** The URL to visit. */
|
|
278
|
+
url?: UrlResolvable;
|
|
279
|
+
/** HTTP verb to use for the request. */
|
|
280
|
+
method?: Method;
|
|
281
|
+
/** Body of the request. */
|
|
282
|
+
data?: RequestData;
|
|
283
|
+
/** Which properties to update for this visit. Other properties will be ignored. */
|
|
284
|
+
only?: string | string[];
|
|
285
|
+
/** Which properties not to update for this visit. Other properties will be updated. */
|
|
286
|
+
except?: string | string[];
|
|
287
|
+
/** Specific headers to add to the request. */
|
|
288
|
+
headers?: Record<string, string>;
|
|
289
|
+
/** The bag in which to put potential errors. */
|
|
290
|
+
errorBag?: string;
|
|
291
|
+
/** Hooks for this visit. */
|
|
292
|
+
hooks?: Partial<Hooks>;
|
|
293
|
+
/** If `true`, force the usage of a `FormData` object. */
|
|
294
|
+
useFormData?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/** An axios visit being made. */
|
|
297
|
+
interface PendingVisit {
|
|
298
|
+
/** The URL to which the request is being made. */
|
|
299
|
+
url: URL;
|
|
300
|
+
/** Abort controller associated to this request. */
|
|
301
|
+
controller: AbortController;
|
|
302
|
+
/** Options for the associated visit. */
|
|
303
|
+
options: VisitOptions;
|
|
304
|
+
/** Visit identifier. */
|
|
305
|
+
id: string;
|
|
306
|
+
}
|
|
307
|
+
/** A page or dialog component. */
|
|
308
|
+
interface View {
|
|
309
|
+
/** Name of the component to use. */
|
|
310
|
+
name: string;
|
|
311
|
+
/** Properties to apply to the component. */
|
|
312
|
+
properties: Properties;
|
|
313
|
+
}
|
|
314
|
+
declare type Property = null | string | number | boolean | Property[] | {
|
|
315
|
+
[name: string]: Property;
|
|
316
|
+
};
|
|
317
|
+
declare type Properties = Record<string | number, Property>;
|
|
318
|
+
interface SwapOptions<T> {
|
|
319
|
+
/** The new component. */
|
|
320
|
+
component: T;
|
|
321
|
+
/** Whether to preserve the state of the component. */
|
|
322
|
+
preserveState?: boolean;
|
|
323
|
+
}
|
|
324
|
+
declare type ViewComponent = any;
|
|
325
|
+
declare type DialogComponent = any;
|
|
326
|
+
declare type ResolveComponent = (name: string) => Promise<ViewComponent>;
|
|
327
|
+
declare type SwapView = (options: SwapOptions<ViewComponent>) => Promise<void>;
|
|
328
|
+
declare type SwapDialog = (options: SwapOptions<DialogComponent>) => Promise<void>;
|
|
329
|
+
/** The payload of a visit request from the server. */
|
|
330
|
+
interface VisitPayload {
|
|
331
|
+
/** The view to use in this request. */
|
|
332
|
+
view: View;
|
|
333
|
+
/** An optional dialog. */
|
|
334
|
+
dialog?: View;
|
|
335
|
+
/** The current page URL. */
|
|
336
|
+
url: string;
|
|
337
|
+
/** The current asset version. */
|
|
338
|
+
version: string;
|
|
339
|
+
}
|
|
340
|
+
interface Progress {
|
|
341
|
+
/** Base event. */
|
|
342
|
+
event: AxiosProgressEvent;
|
|
343
|
+
/** Computed percentage. */
|
|
344
|
+
percentage: Readonly<number>;
|
|
345
|
+
}
|
|
346
|
+
interface Errors {
|
|
347
|
+
[key: string]: string;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface Plugin {
|
|
351
|
+
name: string;
|
|
352
|
+
initialized: (context: InternalRouterContext) => MaybePromise<void>;
|
|
353
|
+
hooks: Partial<Hooks>;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** Router context. */
|
|
357
|
+
interface InternalRouterContext {
|
|
358
|
+
/** The current, normalized URL. */
|
|
359
|
+
url: string;
|
|
360
|
+
/** The current view. */
|
|
361
|
+
view: View;
|
|
362
|
+
/** The current, optional dialog. */
|
|
363
|
+
dialog?: View;
|
|
364
|
+
/** The current local asset version. */
|
|
365
|
+
version: string;
|
|
366
|
+
/** The current adapter's functions. */
|
|
367
|
+
adapter: Adapter;
|
|
368
|
+
/** Scroll positions of the current page's DOM elements. */
|
|
369
|
+
scrollRegions: ScrollRegion[];
|
|
370
|
+
/** Arbitrary state. */
|
|
371
|
+
state: Record<string, any>;
|
|
372
|
+
/** Currently pending visit. */
|
|
373
|
+
activeVisit?: PendingVisit;
|
|
374
|
+
/** History state serializer. */
|
|
375
|
+
serializer: Serializer;
|
|
376
|
+
/** List of plugins. */
|
|
377
|
+
plugins: Plugin[];
|
|
378
|
+
/** Global hooks. */
|
|
379
|
+
hooks: Partial<Record<keyof Hooks, Array<Function>>>;
|
|
380
|
+
}
|
|
381
|
+
/** Adapter-specific functions. */
|
|
382
|
+
interface Adapter {
|
|
383
|
+
/** Resolves a component from the given name. */
|
|
384
|
+
resolveComponent: ResolveComponent;
|
|
385
|
+
/** Swaps to the given view. */
|
|
386
|
+
swapView: SwapView;
|
|
387
|
+
/** Swaps to the given dialog. */
|
|
388
|
+
swapDialog: SwapDialog;
|
|
389
|
+
/** Called when the context is updated. */
|
|
390
|
+
update?: (context: InternalRouterContext) => void;
|
|
391
|
+
}
|
|
392
|
+
interface ScrollRegion {
|
|
393
|
+
top: number;
|
|
394
|
+
left: number;
|
|
395
|
+
}
|
|
396
|
+
/** Provides methods to serialize the state into the history state. */
|
|
397
|
+
interface Serializer {
|
|
398
|
+
serialize: <T>(view: T) => any;
|
|
399
|
+
unserialize: <T>(state: any) => T;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Accesses the hybridly context. */
|
|
403
|
+
declare function useContext(): vue.ComputedRef<Readonly<InternalRouterContext> | undefined>;
|
|
404
|
+
|
|
405
|
+
/** Gets the router. */
|
|
406
|
+
declare function useRouter(): _hybridly_core.Router;
|
|
407
|
+
|
|
408
|
+
declare type Fields = Record<string, any>;
|
|
409
|
+
interface FormOptions<T extends Fields> extends Omit<VisitOptions$1, 'data' | 'url'> {
|
|
410
|
+
fields: T;
|
|
411
|
+
url?: UrlResolvable$1 | (() => UrlResolvable$1);
|
|
412
|
+
key?: string | false;
|
|
413
|
+
timeout?: number;
|
|
414
|
+
reset?: boolean;
|
|
415
|
+
transform?: (fields: T) => Fields;
|
|
416
|
+
}
|
|
417
|
+
declare function useForm<T extends Fields = Fields>(options: FormOptions<T>): {
|
|
418
|
+
reset: (...keys: (keyof T)[]) => void;
|
|
419
|
+
initial: vue.UnwrapRef<vue.DeepReadonly<vue.UnwrapNestedRefs<T>>>;
|
|
420
|
+
fields: vue.UnwrapRef<vue.UnwrapNestedRefs<T>>;
|
|
421
|
+
loaded: any;
|
|
422
|
+
submit: (optionsOverrides?: Omit<VisitOptions$1, 'data'>) => Promise<_hybridly_core.VisitResponse>;
|
|
423
|
+
abort: () => void;
|
|
424
|
+
setErrors: (incoming: Record<string, string>) => void;
|
|
425
|
+
clearErrors: () => void;
|
|
426
|
+
hasErrors: boolean;
|
|
427
|
+
isDirty: boolean;
|
|
428
|
+
errors: vue.UnwrapRef<vue.DeepReadonly<vue.UnwrapNestedRefs<[Record<keyof T, string>] extends [vue.Ref<any>] ? vue.Ref<any> & Record<keyof T, string> : vue.Ref<vue.UnwrapRef<Record<keyof T, string>>>>>>;
|
|
429
|
+
processing: boolean;
|
|
430
|
+
successful: boolean;
|
|
431
|
+
failed: boolean;
|
|
432
|
+
recentlySuccessful: boolean;
|
|
433
|
+
recentlyFailed: boolean;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Returns a ref with a value saved in the history state through Hybridly.
|
|
438
|
+
* The state is linked to a specific browser history entry.
|
|
439
|
+
*/
|
|
440
|
+
declare function useHistoryState<T = any>(key: string, initial: T): vue.Ref<vue.UnwrapRef<T>>;
|
|
441
|
+
|
|
442
|
+
declare type BackForwardCallback = (context: RouterContext) => void;
|
|
443
|
+
declare function useBackForward(): {
|
|
444
|
+
onBackForward: (fn: BackForwardCallback) => void;
|
|
445
|
+
reloadOnBackForward: (options?: VisitOptions$1) => void;
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
declare global {
|
|
449
|
+
/**
|
|
450
|
+
* Paginated data with metadata in a `meta` wrap.
|
|
451
|
+
*/
|
|
452
|
+
interface Paginator<T = any> {
|
|
453
|
+
data: T[];
|
|
454
|
+
meta?: PaginatorMeta;
|
|
455
|
+
links?: PaginatorLink[];
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Paginated data without metadata wrapping.
|
|
459
|
+
*/
|
|
460
|
+
interface UnwrappedPaginator<T = any> extends PaginatorMeta {
|
|
461
|
+
data: T[];
|
|
462
|
+
links: PaginatorLink[];
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
interface PaginatorLink {
|
|
466
|
+
url?: string;
|
|
467
|
+
label: string;
|
|
468
|
+
active: boolean;
|
|
469
|
+
}
|
|
470
|
+
interface PaginatorMeta {
|
|
471
|
+
path: string;
|
|
472
|
+
from: number;
|
|
473
|
+
to: number;
|
|
474
|
+
total: number;
|
|
475
|
+
per_page: number;
|
|
476
|
+
current_page: number;
|
|
477
|
+
last_page: number;
|
|
478
|
+
first_page_url: string;
|
|
479
|
+
last_page_url: string;
|
|
480
|
+
next_page_url: string | undefined;
|
|
481
|
+
prev_page_url: string | undefined;
|
|
482
|
+
links?: PaginatorLink[];
|
|
483
|
+
}
|
|
484
|
+
interface Item {
|
|
485
|
+
url: string | undefined;
|
|
486
|
+
label: string;
|
|
487
|
+
isPage: boolean;
|
|
488
|
+
isActive: boolean;
|
|
489
|
+
isPrevious: boolean;
|
|
490
|
+
isNext: boolean;
|
|
491
|
+
isCurrent: boolean;
|
|
492
|
+
isSeparator: boolean;
|
|
493
|
+
}
|
|
494
|
+
declare function usePaginator<T = any>(paginator: UnwrappedPaginator<T> | Paginator<T> | PaginatorMeta): {
|
|
495
|
+
pages: Item[];
|
|
496
|
+
items: Item[];
|
|
497
|
+
previous: Item;
|
|
498
|
+
next: Item;
|
|
499
|
+
first: {
|
|
500
|
+
isActive: boolean;
|
|
501
|
+
label: string;
|
|
502
|
+
url: string | undefined;
|
|
503
|
+
isPage: boolean;
|
|
504
|
+
isPrevious: boolean;
|
|
505
|
+
isNext: boolean;
|
|
506
|
+
isCurrent: boolean;
|
|
507
|
+
isSeparator: boolean;
|
|
508
|
+
};
|
|
509
|
+
last: {
|
|
510
|
+
isActive: boolean;
|
|
511
|
+
label: string;
|
|
512
|
+
url: string | undefined;
|
|
513
|
+
isPage: boolean;
|
|
514
|
+
isPrevious: boolean;
|
|
515
|
+
isNext: boolean;
|
|
516
|
+
isCurrent: boolean;
|
|
517
|
+
isSeparator: boolean;
|
|
518
|
+
};
|
|
519
|
+
total: number;
|
|
520
|
+
from: number;
|
|
521
|
+
to: number;
|
|
522
|
+
};
|
|
523
|
+
|
|
524
|
+
declare type Layout = ComponentOptions | (() => ComponentOptions) | [ComponentOptions];
|
|
525
|
+
/**
|
|
526
|
+
* Sets the persistent layout for this page.
|
|
527
|
+
*/
|
|
528
|
+
declare function useLayout(layout: Layout): void;
|
|
529
|
+
|
|
530
|
+
interface RouterConfiguration {
|
|
531
|
+
url: string;
|
|
532
|
+
port?: number;
|
|
533
|
+
defaults: Record<string, any>;
|
|
534
|
+
}
|
|
535
|
+
interface RouteDefinition {
|
|
536
|
+
uri: string;
|
|
537
|
+
methods: Method$1[];
|
|
538
|
+
bindings: Record<string, string>;
|
|
539
|
+
domain?: string;
|
|
540
|
+
wheres?: Record<string, string>;
|
|
541
|
+
}
|
|
542
|
+
interface RouteCollection extends RouterConfiguration {
|
|
543
|
+
routes: Record<string, RouteDefinition>;
|
|
544
|
+
}
|
|
545
|
+
interface GlobalRouteCollection extends RouteCollection {
|
|
546
|
+
}
|
|
547
|
+
declare type RouteName = keyof GlobalRouteCollection['routes'];
|
|
548
|
+
declare type RouteParameters<T extends RouteName> = Record<keyof GlobalRouteCollection['routes'][T]['bindings'], any> & Record<string, any>;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Generates a route from the given route name.
|
|
552
|
+
*/
|
|
553
|
+
declare function route<T extends RouteName>(name: T, parameters?: RouteParameters<T>, absolute?: boolean): string;
|
|
554
|
+
|
|
555
|
+
export { AutoImportResolverOptions, GlobalRouteCollection, HybridlyImports, HybridlyResolver, Layout, RouteCollection, RouteDefinition, RouteName, RouteParameters, RouterConfiguration, RouterLink, initializeHybridly, route, useBackForward, useContext, useForm, useHistoryState, useLayout, usePaginator, useProperties, useProperty, useRouter };
|