@hybridly/vue 0.4.1 → 0.4.3

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.
@@ -0,0 +1,830 @@
1
+ import * as vue from 'vue';
2
+ import { App, Plugin as Plugin$2, h, PropType, ComputedRef, DeepReadonly, Ref, MaybeRefOrGetter } from 'vue';
3
+ import * as _hybridly_core from '@hybridly/core';
4
+ import { RouterContextOptions, Plugin as Plugin$1, RouterContext, Method as Method$1, HybridRequestOptions as HybridRequestOptions$1, UrlResolvable as UrlResolvable$1, registerHook as registerHook$1 } from '@hybridly/core';
5
+ export { can, route, router } from '@hybridly/core';
6
+ import { Axios, AxiosResponse, AxiosProgressEvent } from 'axios';
7
+ import { ProgressOptions } from '@hybridly/progress-plugin';
8
+ import * as _vue_shared from '@vue/shared';
9
+ import { RequestData } from '@hybridly/utils';
10
+ import { SearchableObject, Path, PathValue } from '@clickbar/dot-diver';
11
+
12
+ /**
13
+ * Initializes Hybridly's router and context.
14
+ */
15
+ declare function initializeHybridly(options?: InitializeOptions): Promise<any>;
16
+ interface InitializeOptions {
17
+ /** Callback that gets executed before Vue is mounted. */
18
+ enhanceVue?: (vue: App<Element>) => any;
19
+ /** ID of the app element. */
20
+ id?: string;
21
+ /** Clean up the host element's payload dataset after loading. */
22
+ cleanup?: boolean;
23
+ /** Whether to set up the devtools plugin. */
24
+ devtools?: boolean;
25
+ /** Whether to display response error modals. */
26
+ responseErrorModals?: boolean;
27
+ /** Custom history state serialization functions. */
28
+ serializer?: RouterContextOptions['serializer'];
29
+ /** Progressbar options. */
30
+ progress?: false | Partial<ProgressOptions>;
31
+ /** Sets up the hybridly router. */
32
+ setup?: (options: SetupArguments) => any;
33
+ /** List of Hybridly plugins. */
34
+ plugins?: Plugin$1[];
35
+ /** Custom Axios instance. */
36
+ axios?: Axios;
37
+ }
38
+ interface SetupArguments {
39
+ /** DOM element to mount Vue on. */
40
+ element: Element;
41
+ /** Hybridly wrapper component. */
42
+ wrapper: any;
43
+ /** Hybridly wrapper component properties. */
44
+ props: {
45
+ context: RouterContext;
46
+ };
47
+ /** Vue plugin that registers the devtools. */
48
+ hybridly: Plugin$2;
49
+ /** Renders the wrapper. */
50
+ render: () => ReturnType<typeof h>;
51
+ }
52
+
53
+ declare const RouterLink: vue.DefineComponent<{
54
+ href: {
55
+ type: StringConstructor;
56
+ required: false;
57
+ default: undefined;
58
+ };
59
+ as: {
60
+ type: (ObjectConstructor | StringConstructor)[];
61
+ default: string;
62
+ };
63
+ method: {
64
+ type: PropType<"delete" | Method$1 | "get" | "post" | "put" | "patch">;
65
+ default: string;
66
+ };
67
+ data: {
68
+ type: PropType<RequestData>;
69
+ default: () => {};
70
+ };
71
+ external: {
72
+ type: BooleanConstructor;
73
+ default: boolean;
74
+ };
75
+ disabled: {
76
+ type: BooleanConstructor;
77
+ default: boolean;
78
+ };
79
+ options: {
80
+ type: PropType<Omit<HybridRequestOptions$1, "data" | "url" | "method">>;
81
+ default: () => {};
82
+ };
83
+ text: {
84
+ type: StringConstructor;
85
+ required: false;
86
+ default: undefined;
87
+ };
88
+ preload: {
89
+ type: PropType<boolean | "hover" | "mount">;
90
+ default: boolean;
91
+ };
92
+ }, (props: _vue_shared.LooseRequired<{
93
+ readonly data: RequestData;
94
+ readonly method: "delete" | Method$1 | "get" | "post" | "put" | "patch";
95
+ readonly options: Omit<HybridRequestOptions$1, "data" | "url" | "method">;
96
+ readonly as: string | Record<string, any>;
97
+ readonly external: boolean;
98
+ readonly disabled: boolean;
99
+ readonly preload: boolean | "hover" | "mount";
100
+ readonly text?: string | undefined;
101
+ readonly href?: string | undefined;
102
+ } & {}>) => vue.VNode<vue.RendererNode, vue.RendererElement, {
103
+ [key: string]: any;
104
+ }>, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{
105
+ href: {
106
+ type: StringConstructor;
107
+ required: false;
108
+ default: undefined;
109
+ };
110
+ as: {
111
+ type: (ObjectConstructor | StringConstructor)[];
112
+ default: string;
113
+ };
114
+ method: {
115
+ type: PropType<"delete" | Method$1 | "get" | "post" | "put" | "patch">;
116
+ default: string;
117
+ };
118
+ data: {
119
+ type: PropType<RequestData>;
120
+ default: () => {};
121
+ };
122
+ external: {
123
+ type: BooleanConstructor;
124
+ default: boolean;
125
+ };
126
+ disabled: {
127
+ type: BooleanConstructor;
128
+ default: boolean;
129
+ };
130
+ options: {
131
+ type: PropType<Omit<HybridRequestOptions$1, "data" | "url" | "method">>;
132
+ default: () => {};
133
+ };
134
+ text: {
135
+ type: StringConstructor;
136
+ required: false;
137
+ default: undefined;
138
+ };
139
+ preload: {
140
+ type: PropType<boolean | "hover" | "mount">;
141
+ default: boolean;
142
+ };
143
+ }>>, {
144
+ data: RequestData;
145
+ text: string;
146
+ href: string;
147
+ method: "delete" | Method$1 | "get" | "post" | "put" | "patch";
148
+ options: Omit<HybridRequestOptions$1, "data" | "url" | "method">;
149
+ as: string | Record<string, any>;
150
+ external: boolean;
151
+ disabled: boolean;
152
+ preload: boolean | "hover" | "mount";
153
+ }, {}>;
154
+
155
+ /** Accesses all current properties. */
156
+ declare function useProperties<T extends object, Global extends GlobalHybridlyProperties>(): vue.DeepReadonly<vue.UnwrapNestedRefs<T & Global>>;
157
+ /** Accesses a property with a dot notation. */
158
+ declare function useProperty<Override = never, T extends SearchableObject = GlobalHybridlyProperties, P extends Path<T> & string = Path<T> & string, ReturnType = [Override] extends [never] ? PathValue<T, P> : Override>(path: [Override] extends [never] ? P : string): ComputedRef<ReturnType>;
159
+ /**
160
+ * Sets the property at the given path to the given value.
161
+ * Note: this helper is experimental and may change in the future.
162
+ */
163
+ declare function setProperty<Override = never, T extends SearchableObject = GlobalHybridlyProperties, P extends Path<T> & string = Path<T> & string, ValueType = [Override] extends [never] ? PathValue<T, P> : Override>(path: [Override] extends [never] ? P : string, value: ValueType): void;
164
+
165
+ type UrlResolvable = string | URL | Location;
166
+ type UrlTransformable = BaseUrlTransformable | ((string: URL) => BaseUrlTransformable);
167
+ type BaseUrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toString'>> & {
168
+ query?: any;
169
+ trailingSlash?: boolean;
170
+ };
171
+
172
+ type MaybePromise<T> = T | Promise<T>;
173
+
174
+ interface RequestHooks {
175
+ /**
176
+ * Called before a navigation request is going to happen.
177
+ */
178
+ before: (options: HybridRequestOptions, context: InternalRouterContext) => MaybePromise<any | boolean>;
179
+ /**
180
+ * Called before the request of a navigation is going to happen.
181
+ */
182
+ start: (context: InternalRouterContext) => MaybePromise<any>;
183
+ /**
184
+ * Called when progress on the request is being made.
185
+ */
186
+ progress: (progress: Progress, context: InternalRouterContext) => MaybePromise<any>;
187
+ /**
188
+ * Called when data is received after a request for a navigation.
189
+ */
190
+ data: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
191
+ /**
192
+ * Called when a request is successful and there is no error.
193
+ */
194
+ success: (payload: HybridPayload, context: InternalRouterContext) => MaybePromise<any>;
195
+ /**
196
+ * Called when a request is successful but there were errors.
197
+ */
198
+ error: (errors: Errors$1, context: InternalRouterContext) => MaybePromise<any>;
199
+ /**
200
+ * Called when a request has been aborted.
201
+ */
202
+ abort: (context: InternalRouterContext) => MaybePromise<any>;
203
+ /**
204
+ * Called when a response to a request is not a valid hybrid response.
205
+ */
206
+ invalid: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
207
+ /**
208
+ * Called when an unknowne exception was triggered.
209
+ */
210
+ exception: (error: Error, context: InternalRouterContext) => MaybePromise<any>;
211
+ /**
212
+ * Called whenever the request failed, for any reason, in addition to other hooks.
213
+ */
214
+ fail: (context: InternalRouterContext) => MaybePromise<any>;
215
+ /**
216
+ * Called after a request has been made, even if it didn't succeed.
217
+ */
218
+ after: (context: InternalRouterContext) => MaybePromise<any>;
219
+ }
220
+ interface Hooks extends RequestHooks {
221
+ /**
222
+ * Called when Hybridly's context is initialized.
223
+ */
224
+ initialized: (context: InternalRouterContext) => MaybePromise<any>;
225
+ /**
226
+ * Called after Hybridly's initial page load.
227
+ */
228
+ ready: (context: InternalRouterContext) => MaybePromise<any>;
229
+ /**
230
+ * Called when a back-forward navigation occurs.
231
+ */
232
+ backForward: (state: any, context: InternalRouterContext) => MaybePromise<any>;
233
+ /**
234
+ * Called when a component navigation is being made.
235
+ */
236
+ navigating: (options: NavigationOptions, context: InternalRouterContext) => MaybePromise<any>;
237
+ /**
238
+ * Called when a component has been navigated to.
239
+ */
240
+ navigated: (options: NavigationOptions, context: InternalRouterContext) => MaybePromise<any>;
241
+ /**
242
+ * Called when a component has been navigated to and was mounted by the adapter.
243
+ */
244
+ mounted: (context: InternalRouterContext) => MaybePromise<any>;
245
+ }
246
+
247
+ interface RoutingConfiguration {
248
+ url: string;
249
+ port?: number;
250
+ defaults: Record<string, any>;
251
+ routes: Record<string, RouteDefinition>;
252
+ }
253
+ interface RouteDefinition {
254
+ uri: string;
255
+ method: Method[];
256
+ bindings: Record<string, string>;
257
+ domain?: string;
258
+ wheres?: Record<string, string>;
259
+ name: string;
260
+ }
261
+
262
+ type ConditionalNavigationOption<T extends boolean | string> = T | ((payload: NavigationOptions) => T);
263
+ interface NavigationOptions {
264
+ /** View to navigate to. */
265
+ payload?: HybridPayload;
266
+ /**
267
+ * Whether to replace the current history state instead of adding
268
+ * one. This affects the browser's "back" and "forward" features.
269
+ */
270
+ replace?: ConditionalNavigationOption<boolean>;
271
+ /** Whether to preserve the scrollbars positions on the page. */
272
+ preserveScroll?: ConditionalNavigationOption<boolean>;
273
+ /** Whether to preserve the current page component's state. */
274
+ preserveState?: ConditionalNavigationOption<boolean>;
275
+ /** Whether to preserve the current URL. */
276
+ preserveUrl?: ConditionalNavigationOption<boolean>;
277
+ /**
278
+ * Properties of the given URL to override.
279
+ * @example
280
+ * ```ts
281
+ * router.get('/login?redirect=/', {
282
+ * transformUrl: { search: '' }
283
+ * }
284
+ * ```
285
+ */
286
+ transformUrl?: UrlTransformable;
287
+ /**
288
+ * Defines whether the history state should be updated.
289
+ * @internal This is an advanced property meant to be used internally.
290
+ */
291
+ updateHistoryState?: boolean;
292
+ /**
293
+ * Defines whether this navigation is a back/forward navigation from the popstate event.
294
+ * @internal This is an advanced property meant to be used internally.
295
+ */
296
+ isBackForward?: boolean;
297
+ }
298
+ type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
299
+ interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> {
300
+ /** The URL to navigation. */
301
+ url?: UrlResolvable;
302
+ /** HTTP verb to use for the request. */
303
+ method?: Method | Lowercase<Method>;
304
+ /** Body of the request. */
305
+ data?: RequestData;
306
+ /** Which properties to update for this navigation. Other properties will be ignored. */
307
+ only?: string | string[];
308
+ /** Which properties not to update for this navigation. Other properties will be updated. */
309
+ except?: string | string[];
310
+ /** Specific headers to add to the request. */
311
+ headers?: Record<string, string>;
312
+ /** The bag in which to put potential errors. */
313
+ errorBag?: string;
314
+ /** Hooks for this navigation. */
315
+ hooks?: Partial<RequestHooks>;
316
+ /** If `true`, force the usage of a `FormData` object. */
317
+ useFormData?: boolean;
318
+ /**
319
+ * If `false`, disable automatic form spoofing.
320
+ * @see https://laravel.com/docs/9.x/routing#form-method-spoofing
321
+ */
322
+ spoof?: boolean;
323
+ /**
324
+ * If `false`, does not trigger the progress bar for this request.
325
+ */
326
+ progress?: boolean;
327
+ }
328
+ /** A navigation being made. */
329
+ interface PendingNavigation {
330
+ /** The URL to which the request is being made. */
331
+ url: URL;
332
+ /** Abort controller associated to this request. */
333
+ controller: AbortController;
334
+ /** Options for the associated hybrid request. */
335
+ options: HybridRequestOptions;
336
+ /** Navigation identifier. */
337
+ id: string;
338
+ /** Current status. */
339
+ status: 'pending' | 'success' | 'error';
340
+ }
341
+ /** A page or dialog component. */
342
+ interface View {
343
+ /** Name of the component to use. */
344
+ component: string;
345
+ /** Properties to apply to the component. */
346
+ properties: Properties;
347
+ }
348
+ interface Dialog extends View {
349
+ /** URL that is the base background page when navigating to the dialog directly. */
350
+ baseUrl: string;
351
+ /** URL to which the dialog should redirect when closed. */
352
+ redirectUrl: string;
353
+ /** Unique identifier for this modal's lifecycle. */
354
+ key: string;
355
+ }
356
+ type Property = null | string | number | boolean | Property[] | {
357
+ [name: string]: Property;
358
+ };
359
+ type Properties = Record<string | number, Property>;
360
+ interface SwapOptions<T> {
361
+ /** The new component. */
362
+ component: T;
363
+ /** The new properties. */
364
+ properties?: any;
365
+ /** Whether to preserve the state of the component. */
366
+ preserveState?: boolean;
367
+ /** Current dialog. */
368
+ dialog?: Dialog;
369
+ }
370
+ type ViewComponent = any;
371
+ type ResolveComponent = (name: string) => Promise<ViewComponent>;
372
+ type SwapView = (options: SwapOptions<ViewComponent>) => Promise<void>;
373
+ /** The payload of a navigation request from the server. */
374
+ interface HybridPayload {
375
+ /** The view to use in this request. */
376
+ view: View;
377
+ /** An optional dialog. */
378
+ dialog?: Dialog;
379
+ /** The current page URL. */
380
+ url: string;
381
+ /** The current asset version. */
382
+ version: string;
383
+ }
384
+ interface Progress {
385
+ /** Base event. */
386
+ event: AxiosProgressEvent;
387
+ /** Computed percentage. */
388
+ percentage: Readonly<number>;
389
+ }
390
+ type Errors$1 = any;
391
+
392
+ interface Plugin extends Partial<Hooks> {
393
+ /** Identifier of the plugin. */
394
+ name: string;
395
+ }
396
+
397
+ /** Router context. */
398
+ interface InternalRouterContext {
399
+ /** The current, normalized URL. */
400
+ url: string;
401
+ /** The current view. */
402
+ view: View;
403
+ /** The current, optional dialog. */
404
+ dialog?: Dialog;
405
+ /** The current local asset version. */
406
+ version: string;
407
+ /** The current adapter's functions. */
408
+ adapter: ResolvedAdapter;
409
+ /** Scroll positions of the current page's DOM elements. */
410
+ scrollRegions: ScrollRegion[];
411
+ /** Arbitrary state. */
412
+ memo: Record<string, any>;
413
+ /** Currently pending navigation. */
414
+ pendingNavigation?: PendingNavigation;
415
+ /** History state serializer. */
416
+ serializer: Serializer;
417
+ /** List of plugins. */
418
+ plugins: Plugin[];
419
+ /** Global hooks. */
420
+ hooks: Partial<Record<keyof Hooks, Array<Function>>>;
421
+ /** The Axios instance. */
422
+ axios: Axios;
423
+ /** Routing configuration. */
424
+ routing?: RoutingConfiguration;
425
+ /** Whether to display response error modals. */
426
+ responseErrorModals?: boolean;
427
+ /** Cache of preload requests. */
428
+ preloadCache: Map<string, AxiosResponse>;
429
+ }
430
+ /** Adapter-specific functions. */
431
+ interface Adapter {
432
+ /** Resolves a component from the given name. */
433
+ resolveComponent: ResolveComponent;
434
+ /** Called when the view is swapped. */
435
+ onViewSwap: SwapView;
436
+ /** Called when the context is updated. */
437
+ onContextUpdate?: (context: InternalRouterContext) => void;
438
+ /** Called when a dialog is closed. */
439
+ onDialogClose?: (context: InternalRouterContext) => void;
440
+ /** Called when Hybridly is waiting for a component to be mounted. The given callback should be executed after the view component is mounted. */
441
+ executeOnMounted: (callback: Function) => void;
442
+ }
443
+ interface ResolvedAdapter extends Adapter {
444
+ updateRoutingConfiguration: (routing?: RoutingConfiguration) => void;
445
+ }
446
+ interface ScrollRegion {
447
+ top: number;
448
+ left: number;
449
+ }
450
+ /** Provides methods to serialize the state into the history state. */
451
+ interface Serializer {
452
+ serialize: <T>(view: T) => string;
453
+ unserialize: <T>(state?: string) => T | undefined;
454
+ }
455
+
456
+ /** Accesses the hybridly context. */
457
+ declare function useContext(): vue.ComputedRef<Readonly<InternalRouterContext> | undefined>;
458
+
459
+ type Errors<T extends SearchableObject> = {
460
+ [K in keyof T]?: T[K] extends Record<string, any> ? Errors<T[K]> : string;
461
+ };
462
+ interface FormOptions<T extends SearchableObject> extends Omit<HybridRequestOptions$1, 'data' | 'url'> {
463
+ fields: T;
464
+ url?: UrlResolvable$1 | (() => UrlResolvable$1);
465
+ key?: string | false;
466
+ /**
467
+ * Defines the delay after which the `recentlySuccessful` and `recentlyFailed` variables are reset to `false`.
468
+ */
469
+ timeout?: number;
470
+ /**
471
+ * Resets the fields of the form to their initial value after a successful submission.
472
+ * @default true
473
+ */
474
+ reset?: boolean;
475
+ /**
476
+ * Updates the initial values from the form after a successful submission.
477
+ * @default false
478
+ */
479
+ updateInitials?: boolean;
480
+ /**
481
+ * Callback executed before the form submission for transforming the fields.
482
+ */
483
+ transform?: (fields: T) => any;
484
+ }
485
+ declare function useForm<T extends SearchableObject, P extends Path<T> & string = Path<T> & string>(options: FormOptions<T>): {
486
+ reset: (...keys: P[]) => void;
487
+ clear: (...keys: P[]) => void;
488
+ fields: vue.UnwrapRef<T>;
489
+ abort: () => void;
490
+ setErrors: (incoming: Errors<T>) => void;
491
+ clearErrors: (...keys: P[]) => void;
492
+ clearError: (key: P) => void;
493
+ setInitial: (newInitial: Partial<T>) => void;
494
+ hasDirty: (...keys: P[]) => boolean;
495
+ submitWith: (optionsOverrides?: Omit<HybridRequestOptions$1, 'data'>) => Promise<_hybridly_core.NavigationResponse>;
496
+ submitWithOptions: (optionsOverrides?: Omit<HybridRequestOptions$1, 'data'>) => Promise<_hybridly_core.NavigationResponse>;
497
+ submit: () => Promise<_hybridly_core.NavigationResponse>;
498
+ hasErrors: boolean;
499
+ initial: vue.UnwrapRef<DeepReadonly<T>>;
500
+ loaded: any;
501
+ progress: {
502
+ readonly event: {
503
+ readonly loaded: number;
504
+ readonly total?: number | undefined;
505
+ readonly progress?: number | undefined;
506
+ readonly bytes: number;
507
+ readonly rate?: number | undefined;
508
+ readonly estimated?: number | undefined;
509
+ readonly upload?: boolean | undefined;
510
+ readonly download?: boolean | undefined;
511
+ readonly event?: any;
512
+ };
513
+ readonly percentage: number;
514
+ } | undefined;
515
+ isDirty: boolean;
516
+ errors: DeepReadonly<vue.UnwrapRef<Errors<T>>>;
517
+ processing: boolean;
518
+ successful: boolean;
519
+ failed: boolean;
520
+ recentlySuccessful: boolean;
521
+ recentlyFailed: boolean;
522
+ };
523
+
524
+ /**
525
+ * Returns a ref with a value saved in the history state through Hybridly.
526
+ * The state is linked to a specific browser history entry.
527
+ */
528
+ declare function useHistoryState<T = any>(key: string, initial: T): vue.Ref<vue.UnwrapRef<T>>;
529
+
530
+ type BackForwardCallback = (context: RouterContext) => void;
531
+ declare function useBackForward(): {
532
+ onBackForward: (fn: BackForwardCallback) => void;
533
+ reloadOnBackForward: (options?: HybridRequestOptions$1) => void;
534
+ };
535
+
536
+ declare global {
537
+ /**
538
+ * Paginated data with metadata in a `meta` wrap.
539
+ */
540
+ interface Paginator<T = any> {
541
+ data: T[];
542
+ meta: PaginatorMeta;
543
+ links: PaginatorLink[];
544
+ }
545
+ /**
546
+ * Paginated data without metadata wrapping.
547
+ */
548
+ interface UnwrappedPaginator<T = any> extends PaginatorMeta {
549
+ data: T[];
550
+ links: PaginatorLink[];
551
+ }
552
+ }
553
+ interface PaginatorLink {
554
+ url?: string;
555
+ label: string;
556
+ active: boolean;
557
+ }
558
+ interface PaginatorMeta {
559
+ path: string;
560
+ from: number;
561
+ to: number;
562
+ total: number;
563
+ per_page: number;
564
+ current_page: number;
565
+ last_page: number;
566
+ first_page_url: string;
567
+ last_page_url: string;
568
+ next_page_url: string | undefined;
569
+ prev_page_url: string | undefined;
570
+ links?: PaginatorLink[];
571
+ }
572
+ interface Item {
573
+ url: string | undefined;
574
+ label: string;
575
+ isPage: boolean;
576
+ isActive: boolean;
577
+ isPrevious: boolean;
578
+ isNext: boolean;
579
+ isCurrent: boolean;
580
+ isSeparator: boolean;
581
+ }
582
+ declare function usePaginator<T = any>(paginator: UnwrappedPaginator<T> | Paginator<T> | PaginatorMeta): {
583
+ pages: Item[];
584
+ items: Item[];
585
+ previous: Item;
586
+ next: Item;
587
+ first: {
588
+ isActive: boolean;
589
+ label: string;
590
+ url: string | undefined;
591
+ isPage: boolean;
592
+ isPrevious: boolean;
593
+ isNext: boolean;
594
+ isCurrent: boolean;
595
+ isSeparator: boolean;
596
+ };
597
+ last: {
598
+ isActive: boolean;
599
+ label: string;
600
+ url: string | undefined;
601
+ isPage: boolean;
602
+ isPrevious: boolean;
603
+ isNext: boolean;
604
+ isCurrent: boolean;
605
+ isSeparator: boolean;
606
+ };
607
+ total: number;
608
+ from: number;
609
+ to: number;
610
+ };
611
+
612
+ type Layout = any;
613
+ /**
614
+ * Sets the persistent layout for this page.
615
+ */
616
+ declare function defineLayout<T extends Record<string, K>, K = any>(layout: Layout, properties?: T): void;
617
+ declare function defineLayout(layouts: Layout[]): void;
618
+ /**
619
+ * Sets or gets the properties for the current persistent layout.
620
+ */
621
+ declare function defineLayoutProperties<T extends Record<string, K>, K = any>(properties: T): void;
622
+
623
+ /**
624
+ * Registers a global hook.
625
+ * If called inside a component, unregisters after the component is unmounted.
626
+ */
627
+ declare const registerHook: typeof registerHook$1;
628
+
629
+ /**
630
+ * Exposes utilities related to the dialogs.
631
+ */
632
+ declare function useDialog(): {
633
+ /** Closes the dialog. */
634
+ close: () => void;
635
+ /** Closes the dialog without a server round-trip. */
636
+ closeLocally: () => void;
637
+ /** Unmounts the dialog. Should be called after its closing animations. */
638
+ unmount: () => void;
639
+ /** Whether the dialog is shown. */
640
+ show: vue.ComputedRef<boolean | undefined>;
641
+ /** Properties of the dialog. */
642
+ properties: vue.ComputedRef<Properties | undefined>;
643
+ };
644
+
645
+ type SortDirection = 'asc' | 'desc';
646
+ type AvailableHybridRequestOptions = Omit<HybridRequestOptions$1, 'url' | 'data'>;
647
+ interface ToggleSortOptions extends AvailableHybridRequestOptions {
648
+ direction?: SortDirection;
649
+ }
650
+ interface BindFilterOptions<T> extends AvailableHybridRequestOptions {
651
+ transformValue?: (value?: T) => any;
652
+ /** If specified, this callback will watch the ref and apply */
653
+ watch?: (ref: Ref<T>, cb: any) => void;
654
+ }
655
+ declare global {
656
+ interface FilterRefinement {
657
+ /**
658
+ * Whether this filter is currently active.
659
+ */
660
+ is_active: boolean;
661
+ /**
662
+ * The type of this filter.
663
+ */
664
+ type: 'trashed' | 'callback' | 'exact' | 'similarity:loose' | 'similarity:begins_with_strict' | 'similarity:ends_with_strict' | string;
665
+ /**
666
+ * The label of the filter.
667
+ */
668
+ label: string;
669
+ /**
670
+ * The metadata attributes of the filter.
671
+ */
672
+ metadata: Record<string, any>;
673
+ /**
674
+ * The name of the fitler.
675
+ */
676
+ name: string;
677
+ /**
678
+ * The current value of the filter.
679
+ */
680
+ value: any;
681
+ /**
682
+ * Whether this filter is hidden.
683
+ */
684
+ hidden: boolean;
685
+ /**
686
+ * The default value of the filter.
687
+ */
688
+ default: any;
689
+ }
690
+ interface SortRefinement {
691
+ /**
692
+ * Whether this sort is currently active.
693
+ */
694
+ is_active: boolean;
695
+ /**
696
+ * The current direction of the sort.
697
+ */
698
+ direction?: SortDirection;
699
+ /**
700
+ * The default direction of the sort.
701
+ */
702
+ default?: SortDirection;
703
+ /**
704
+ * The label of the sort.
705
+ */
706
+ label: string;
707
+ /**
708
+ * The metadata attributes of the sort.
709
+ */
710
+ metadata: Record<string, any>;
711
+ /**
712
+ * The name of the sort.
713
+ */
714
+ name: string;
715
+ /**
716
+ * The value corresponding to the descending sort.
717
+ */
718
+ desc: string;
719
+ /**
720
+ * The value corresponding to the ascending sort.
721
+ */
722
+ asc: string;
723
+ /**
724
+ * The value that will be applied on toggle.
725
+ */
726
+ next: string;
727
+ /**
728
+ * Whether this sort is hidden.
729
+ */
730
+ hidden: boolean;
731
+ }
732
+ interface Refinements {
733
+ /**
734
+ * The list of available filters.
735
+ */
736
+ filters: Array<FilterRefinement>;
737
+ /**
738
+ * The list of available sorts.
739
+ */
740
+ sorts: Array<SortRefinement>;
741
+ /**
742
+ * The URL scope for these refinements.
743
+ */
744
+ scope?: string;
745
+ /**
746
+ * The scope keys for these refinements.
747
+ */
748
+ keys: {
749
+ /**
750
+ * The scope key for sorting.
751
+ */
752
+ sorts: string;
753
+ /**
754
+ * The scope key for filtering.
755
+ */
756
+ filters: string;
757
+ };
758
+ }
759
+ }
760
+ declare function useRefinements<Properties extends object, RefinementsKey extends {
761
+ [K in keyof Properties]: Properties[K] extends Refinements ? K : never;
762
+ }[keyof Properties]>(properties: Properties, refinementsKeys: RefinementsKey, defaultOptions?: AvailableHybridRequestOptions): {
763
+ /**
764
+ * Binds a named filter to a ref, applying filters when it changes and updating the ref accordingly.
765
+ */
766
+ bindFilter: <T = any>(name: string, options?: BindFilterOptions<T>) => Ref<T>;
767
+ /**
768
+ * Available filters.
769
+ */
770
+ filters: FilterRefinement[];
771
+ /**
772
+ * Available sorts.
773
+ */
774
+ sorts: SortRefinement[];
775
+ /**
776
+ * Gets a filter by name.
777
+ */
778
+ getFilter: (name: string) => FilterRefinement | undefined;
779
+ /**
780
+ * Gets a sort by name.
781
+ */
782
+ getSort: (name: string) => SortRefinement | undefined;
783
+ /**
784
+ * Resets all filters and sorts.
785
+ */
786
+ reset: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
787
+ /**
788
+ * Toggles the specified sort.
789
+ */
790
+ toggleSort: (name: string, options?: ToggleSortOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
791
+ /**
792
+ * Whether a sort is active.
793
+ */
794
+ isSorting: (name?: string) => boolean;
795
+ /**
796
+ * Whether a filter is active.
797
+ */
798
+ isFiltering: (name?: string) => boolean;
799
+ /**
800
+ * The current sorts.
801
+ */
802
+ currentSorts: () => Array<SortRefinement>;
803
+ /**
804
+ * The current filters.
805
+ */
806
+ currentFilters: () => Array<FilterRefinement>;
807
+ /**
808
+ * Clears the given filter.
809
+ */
810
+ clearFilter: (filter: string, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
811
+ /**
812
+ * Resets all sorts.
813
+ */
814
+ clearSorts: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
815
+ /**
816
+ * Resets all filters.
817
+ */
818
+ clearFilters: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
819
+ /**
820
+ * Applies the given filter.
821
+ */
822
+ applyFilter: (name: string, value: any, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
823
+ };
824
+
825
+ declare function useRoute(): {
826
+ current: Readonly<vue.Ref<string | undefined>>;
827
+ matches: <T extends string>(name: MaybeRefOrGetter<T>, parameters?: Record<string, any> | undefined) => boolean;
828
+ };
829
+
830
+ export { type Layout, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, registerHook, setProperty, useBackForward, useContext, useDialog, useForm, useHistoryState, usePaginator, useProperties, useProperty, useRefinements, useRoute };