@hybridly/vue
Version:
Vue adapter for Hybridly
1,012 lines (994 loc) • 34.7 kB
TypeScript
import * as vue from 'vue';
import { ComputedRef, DeepReadonly, Ref, MaybeRefOrGetter, App, Plugin, h, PropType } from 'vue';
import * as _hybridly_core from '@hybridly/core';
import { HybridRequestOptions, UrlResolvable, RouterContext, registerHook as registerHook$1, RouteName, RouteParameters, RouterContextOptions, Plugin as Plugin$1, Method } from '@hybridly/core';
export { can, route, router } from '@hybridly/core';
import { Axios } from 'axios';
import * as _vue_shared from '@vue/shared';
import { SearchableObject, Path, PathValue } from '@clickbar/dot-diver';
import { FormDataConvertible, RequestData } from '@hybridly/utils';
interface ProgressOptions {
/**
* The delay after which the progress bar will
* appear during navigation, in milliseconds.
*
* @default 250
*/
delay: number;
/**
* The color of the progress bar.
*
* Defaults to #29d.
*/
color: string;
/**
* Whether to include the default NProgress styles.
*
* Defaults to true.
*/
includeCSS: boolean;
/**
* Whether the NProgress spinner will be shown.
*
* Defaults to false.
*/
spinner: boolean;
}
/** Accesses all current properties. */
declare function useProperties<T extends object, Global extends GlobalHybridlyProperties = GlobalHybridlyProperties>(): vue.DeepReadonly<vue.UnwrapNestedRefs<T & Global>>;
/** Accesses a property with a dot notation. */
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>;
/**
* Sets the property at the given path to the given value.
* Note: this helper is experimental and may change in the future.
*/
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;
type Errors<T extends SearchableObject> = {
[K in keyof T]?: T[K] extends Record<string, any> ? Errors<T[K]> : string;
};
type DefaultFormOptions = Pick<FormOptions<object>, 'timeout' | 'reset' | 'updateInitials' | 'progress' | 'preserveScroll' | 'preserveState' | 'preserveUrl' | 'headers' | 'errorBag' | 'spoof' | 'transformUrl' | 'updateHistoryState' | 'useFormData'>;
interface FormOptions<T extends SearchableObject> extends Omit<HybridRequestOptions, 'data' | 'url'> {
fields: T;
url?: UrlResolvable | (() => UrlResolvable);
key?: string | false;
/**
* Defines the delay after which the `recentlySuccessful` and `recentlyFailed` variables are reset to `false`.
*/
timeout?: number;
/**
* Resets the fields of the form to their initial value after a successful submission.
* @default true
*/
reset?: boolean;
/**
* Updates the initial values from the form after a successful submission.
* @default false
*/
updateInitials?: boolean;
/**
* Callback executed before the form submission for transforming the fields.
*/
transform?: (fields: T) => any;
}
declare function useForm<T extends SearchableObject, P extends Path<T> & string = Path<T> & string>(options: FormOptions<T>): {
resetFields: (...keys: P[]) => void;
reset: () => void;
resetSubmissionState: () => void;
clear: (...keys: P[]) => void;
fields: vue.UnwrapRef<T>;
abort: () => void;
setErrors: (incoming: Errors<T>) => void;
clearErrors: (...keys: P[]) => void;
clearError: (key: P) => void;
setInitial: (newInitial: Partial<T>) => void;
hasDirty: (...keys: P[]) => boolean;
submitWith: (optionsOverrides?: Omit<FormOptions<T>, "fields" | "key">) => Promise<_hybridly_core.NavigationResponse>;
submitWithOptions: (optionsOverrides?: Omit<FormOptions<T>, "fields" | "key">) => Promise<_hybridly_core.NavigationResponse>;
submit: () => Promise<_hybridly_core.NavigationResponse>;
hasErrors: boolean;
initial: vue.UnwrapRef<DeepReadonly<T>>;
loaded: DeepReadonly<any>;
progress: {
readonly event: {
readonly loaded: number;
readonly total?: number | undefined;
readonly progress?: number | undefined;
readonly bytes: number;
readonly rate?: number | undefined;
readonly estimated?: number | undefined;
readonly upload?: boolean | undefined;
readonly download?: boolean | undefined;
readonly event?: any;
readonly lengthComputable: boolean;
};
readonly percentage: Readonly<number>;
} | undefined;
isDirty: boolean;
errors: vue.UnwrapRef<DeepReadonly<[Errors<T>] extends [vue.Ref<any, any>] ? _vue_shared.IfAny<vue.Ref<any, any> & Errors<T>, vue.Ref<vue.Ref<any, any> & Errors<T>, vue.Ref<any, any> & Errors<T>>, vue.Ref<any, any> & Errors<T>> : vue.Ref<vue.UnwrapRef<Errors<T>>, Errors<T> | vue.UnwrapRef<Errors<T>>>>>;
processing: boolean;
successful: boolean;
failed: boolean;
recentlySuccessful: boolean;
recentlyFailed: boolean;
};
/**
* Returns a ref with a value saved in the history state through Hybridly.
* The state is linked to a specific browser history entry.
*/
declare function useHistoryState<T = any>(key: string, initial: T): [T] extends [vue.Ref<any, any>] ? _vue_shared.IfAny<T, vue.Ref<T, T>, T> : vue.Ref<vue.UnwrapRef<T>, T | vue.UnwrapRef<T>>;
type BackForwardCallback = (context: RouterContext) => void;
interface UseBackForwardOptions {
/**
* Calls `reloadOnBackForward` immediately.
*/
reload: boolean | HybridRequestOptions;
}
declare function useBackForward(options?: UseBackForwardOptions): {
onBackForward: (fn: BackForwardCallback) => void;
reloadOnBackForward: (options?: HybridRequestOptions) => void;
};
declare global {
/**
* Paginated data with metadata in a `meta` wrap.
*/
interface Paginator<T = any> {
data: T[];
meta: PaginatorMeta;
links: PaginatorLink[];
}
/**
* Simple-paginated data with metadata in a `meta` wrap.
*/
interface SimplePaginator<T = any> {
data: T[];
meta: SimplePaginatorMeta;
}
/**
* Cursor paginator.
*/
interface CursorPaginator<T = any> {
data: T[];
meta: CursorPaginatorMeta;
}
/**
* Paginated data without metadata wrapping.
*/
interface UnwrappedPaginator<T = any> extends PaginatorMeta {
data: T[];
links: PaginatorLink[];
}
}
interface PaginatorLink {
url?: string;
label: string;
active: boolean;
}
interface CursorPaginatorMeta {
path: string;
per_page: number;
prev_cursor: string;
next_cursor: string;
next_page_url?: string;
prev_page_url?: string;
}
interface SimplePaginatorMeta {
path: string;
per_page: number;
current_page: number;
next_page_url?: string;
first_page_url: string;
prev_page_url?: string;
from: number;
to: number;
}
interface PaginatorMeta {
path: string;
from: number;
to: number;
total: number;
per_page: number;
current_page: number;
first_page: number;
last_page: number;
first_page_url: string;
last_page_url: string;
next_page_url?: string;
prev_page_url?: string;
}
/**
* Registers a global hook.
* If called inside a component, unregisters after the component is unmounted.
*/
declare const registerHook: typeof registerHook$1;
type Property = null | string | number | boolean | Property[] | {
[name: string]: Property;
};
type Properties = Record<string | number, Property>;
/**
* Exposes utilities related to the dialogs.
*/
declare function useDialog(): {
/** Closes the dialog. */
close: () => void;
/** Closes the dialog without a server round-trip. */
closeLocally: () => void;
/** Unmounts the dialog. Should be called after its closing animations. */
unmount: () => void;
/** Whether the dialog is shown. */
show: vue.WritableComputedRef<boolean | undefined, boolean | undefined>;
/** Properties of the dialog. */
properties: vue.ComputedRef<Properties | undefined>;
};
type SortDirection = 'asc' | 'desc';
type AvailableHybridRequestOptions = Omit<HybridRequestOptions, 'url' | 'data'>;
interface ToggleSortOptions extends AvailableHybridRequestOptions {
direction?: SortDirection;
/** Additional sort data, only applied when sorting. */
sortData?: {
[key: string]: FormDataConvertible;
};
}
interface BindFilterOptions<T> extends AvailableHybridRequestOptions {
transformValue?: (value?: T) => any;
/** If specified, this callback will be responsible for watching the specified ref that contains the filter value. */
watch?: (ref: Ref<T>, cb: any) => void;
/**
* The debounce time in milliseconds for applying this filter.
* @default 250ms
*/
debounce?: number;
/**
* The debounce time in milliseconds for updating the ref.
* @default 250ms
*/
syncDebounce?: number;
}
declare global {
interface FilterRefinement {
/**
* Whether this filter is currently active.
*/
is_active: boolean;
/**
* The type of this filter.
*/
type: 'trashed' | 'callback' | 'exact' | 'similar:loose' | 'similar:begins_with_strict' | 'similar:ends_with_strict' | string;
/**
* The label of the filter.
*/
label: string;
/**
* The metadata attributes of the filter.
*/
metadata: Record<string, any>;
/**
* The name of the fitler.
*/
name: string;
/**
* The current value of the filter.
*/
value: any;
/**
* Whether this filter is hidden.
*/
hidden: boolean;
/**
* The default value of the filter.
*/
default: any;
}
interface SortRefinement {
/**
* Whether this sort is currently active.
*/
is_active: boolean;
/**
* The current direction of the sort.
*/
direction?: SortDirection;
/**
* The default direction of the sort.
*/
default?: SortDirection;
/**
* The label of the sort.
*/
label: string;
/**
* The metadata attributes of the sort.
*/
metadata: Record<string, any>;
/**
* The name of the sort.
*/
name: string;
/**
* The value corresponding to the descending sort.
*/
desc: string;
/**
* The value corresponding to the ascending sort.
*/
asc: string;
/**
* The value that will be applied on toggle.
*/
next: string;
/**
* Whether this sort is hidden.
*/
hidden: boolean;
}
interface Refinements {
/**
* The list of available filters.
*/
filters: Array<FilterRefinement>;
/**
* The list of available sorts.
*/
sorts: Array<SortRefinement>;
/**
* The URL scope for these refinements.
*/
scope?: string;
/**
* The scope keys for these refinements.
*/
keys: {
/**
* The scope key for sorting.
*/
sorts: string;
/**
* The scope key for filtering.
*/
filters: string;
};
}
}
declare function useRefinements<Properties extends object, RefinementsKey extends {
[K in keyof Properties]: Properties[K] extends Refinements ? K : never;
}[keyof Properties]>(properties: Properties, refinementsKeys: RefinementsKey, defaultOptions?: AvailableHybridRequestOptions): {
/**
* Binds a named filter to a ref, applying filters when it changes and updating the ref accordingly.
*/
bindFilter: <T = any>(name: string, options?: BindFilterOptions<T>) => Ref<T>;
/**
* Available filters.
*/
filters: {
/**
* Applies this filter.
*/
apply: (value: any, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
/**
* Clears this filter.
*/
clear: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/**
* Whether this filter is currently active.
*/
is_active: boolean;
/**
* The type of this filter.
*/
type: "trashed" | "callback" | "exact" | "similar:loose" | "similar:begins_with_strict" | "similar:ends_with_strict" | string;
/**
* The label of the filter.
*/
label: string;
/**
* The metadata attributes of the filter.
*/
metadata: Record<string, any>;
/**
* The name of the fitler.
*/
name: string;
/**
* The current value of the filter.
*/
value: any;
/**
* Whether this filter is hidden.
*/
hidden: boolean;
/**
* The default value of the filter.
*/
default: any;
}[];
/**
* Available sorts.
*/
sorts: {
/**
* Toggles this sort.
*/
toggle: (options?: ToggleSortOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
/**
* Checks if this sort is active.
*/
isSorting: (direction?: SortDirection) => boolean;
/**
* Clears this sort.
*/
clear: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/**
* Whether this sort is currently active.
*/
is_active: boolean;
/**
* The current direction of the sort.
*/
direction?: SortDirection;
/**
* The default direction of the sort.
*/
default?: SortDirection;
/**
* The label of the sort.
*/
label: string;
/**
* The metadata attributes of the sort.
*/
metadata: Record<string, any>;
/**
* The name of the sort.
*/
name: string;
/**
* The value corresponding to the descending sort.
*/
desc: string;
/**
* The value corresponding to the ascending sort.
*/
asc: string;
/**
* The value that will be applied on toggle.
*/
next: string;
/**
* Whether this sort is hidden.
*/
hidden: boolean;
}[];
/**
* The key for the filters.
*/
filtersKey: vue.ComputedRef<string>;
/**
* Gets a filter by name.
*/
getFilter: (name: string) => FilterRefinement | undefined;
/**
* Gets a sort by name.
*/
getSort: (name: string) => SortRefinement | undefined;
/**
* Resets all filters and sorts.
*/
reset: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/**
* Toggles the specified sort.
*/
toggleSort: (name: string, options?: ToggleSortOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
/**
* Whether a sort is active.
*/
isSorting: (name?: string, direction?: SortDirection) => boolean;
/**
* Whether a filter is active.
*/
isFiltering: (name?: string) => boolean;
/**
* The current sorts.
*/
currentSorts: () => Array<SortRefinement>;
/**
* The current filters.
*/
currentFilters: () => Array<FilterRefinement>;
/**
* Clears the given filter.
*/
clearFilter: (filter: string, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/**
* Resets all sorts.
*/
clearSorts: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/**
* Resets all filters.
*/
clearFilters: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/**
* Applies the given filter.
*/
applyFilter: (name: string, value: any, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
};
declare function useRoute(): {
isNavigating: Readonly<vue.Ref<boolean, boolean>>;
current: Readonly<vue.Ref<string | undefined, string | undefined>>;
matches: <T extends RouteName>(name: MaybeRefOrGetter<T>, parameters?: RouteParameters<T>) => boolean;
};
interface BulkSelection<T = any> {
/** Whether all records are selected. */
all: boolean;
/** Included records. */
only: Set<T>;
/** Excluded records. */
except: Set<T>;
}
declare function useBulkSelect<T = any>(): {
allSelected: vue.ComputedRef<boolean>;
selectAll: () => void;
deselectAll: () => void;
select: (...records: T[]) => void;
deselect: (...records: T[]) => void;
toggle: (record: T, force?: boolean) => void;
selected: (record: T) => boolean;
selection: Ref<BulkSelection<T>, BulkSelection<T>>;
bindCheckbox: (key: T) => {
onChange: (event: Event) => void;
checked: boolean;
value: T;
};
};
declare global {
interface Table<T extends Record<string, any> = any, PaginatorKind extends 'cursor' | 'length-aware' | 'simple' = 'length-aware'> {
id: string;
keyName: string;
scope?: string;
columns: Column<T>[];
inlineActions: InlineAction[];
bulkActions: BulkAction[];
records: Array<T>;
paginator: Exclude<PaginatorKind extends 'cursor' ? CursorPaginator<T> : (PaginatorKind extends 'simple' ? SimplePaginator<T> : Paginator<T>), 'data'>;
refinements: Refinements;
endpoint: string;
}
}
interface Column<T extends object = never> {
/** The name of this column. */
name: keyof T;
/** The label of this column. */
label: string;
/** The type of this column. */
type: string;
/** Metadata of this column. */
metadata: Record<string, any>;
}
interface Action {
/** The name of this action. */
name: string;
/** The label of this action. */
label: string;
/** The type of this action. */
type: string;
/** Custom metadata for this action. */
metadata: any;
}
interface BulkAction extends Action {
/** Should deselect all records after action. */
deselect: boolean;
}
interface BulkActionOptions {
/** Force deselecting all records after action. */
deselect?: boolean;
}
interface InlineAction extends Action {
}
type RecordIdentifier = string | number;
type AsRecordType<T extends Record<string, any>> = {
[K in keyof T]: {
extra: Record<string, any>;
value: T[K];
};
};
interface TableDefaultOptions extends AvailableHybridRequestOptions {
/**
* Whether to include existing query parameters in the request.
* @default true
*/
includeQueryParameters?: boolean;
/**
* Additionnal data to send with the requests.
*/
data?: Record<string, FormDataConvertible> | FormDataConvertible;
}
/**
* Provides utilities for working with tables.
*/
declare function useTable<RecordType extends (Props[PropsKey] extends Table<infer T, any> ? AsRecordType<T> : never), PaginatorKindName extends (Props[PropsKey] extends Table<any, infer PaginatorKind> ? PaginatorKind : never), TableType extends (Props[PropsKey] extends Table<any, PaginatorKindName> ? Table<RecordType, PaginatorKindName> : never), Props extends Record<string, unknown>, PropsKey extends keyof Props>(props: Props, key: PropsKey, defaultOptions?: TableDefaultOptions): {
bindFilter: <T = any>(name: string, options?: BindFilterOptions<T>) => vue.Ref<T, T>;
filters: {
apply: (value: any, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
clear: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
is_active: boolean;
type: "trashed" | "callback" | "exact" | "similar:loose" | "similar:begins_with_strict" | "similar:ends_with_strict" | string;
label: string;
metadata: Record<string, any>;
name: string;
value: any;
hidden: boolean;
default: any;
}[];
sorts: {
toggle: (options?: ToggleSortOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
isSorting: (direction?: SortDirection) => boolean;
clear: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
is_active: boolean;
direction?: SortDirection | undefined;
default?: SortDirection | undefined;
label: string;
metadata: Record<string, any>;
name: string;
desc: string;
asc: string;
next: string;
hidden: boolean;
}[];
filtersKey: string;
getFilter: (name: string) => FilterRefinement | undefined;
getSort: (name: string) => SortRefinement | undefined;
reset: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
toggleSort: (name: string, options?: ToggleSortOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
isSorting: (name?: string, direction?: SortDirection) => boolean;
isFiltering: (name?: string) => boolean;
currentSorts: () => Array<SortRefinement>;
currentFilters: () => Array<FilterRefinement>;
clearFilter: (filter: string, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
clearSorts: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
clearFilters: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
applyFilter: (name: string, value: any, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
selectAll: () => void;
deselectAll: () => void;
selectPage: () => void;
deselectPage: () => void;
isPageSelected: boolean;
isSelected: (record: RecordType) => boolean;
allSelected: boolean;
selection: BulkSelection<RecordIdentifier>;
bindCheckbox: (key: RecordIdentifier) => {
onChange: (event: Event) => void;
checked: boolean;
value: RecordIdentifier;
};
toggle: (record: RecordType) => void;
select: (record: RecordType) => void;
deselect: (record: RecordType) => void;
inlineActions: {
/** The name of this action. */
name: string;
/** The label of this action. */
label: string;
/** The type of this action. */
type: string;
/** Custom metadata for this action. */
metadata: any;
/** Executes the action. */
execute: (record: RecordType | RecordIdentifier) => Promise<_hybridly_core.NavigationResponse>;
}[];
bulkActions: {
/** Should deselect all records after action. */
deselect: boolean;
/** The name of this action. */
name: string;
/** The label of this action. */
label: string;
/** The type of this action. */
type: string;
/** Custom metadata for this action. */
metadata: any;
/** Executes the action. */
execute: (options?: BulkActionOptions) => Promise<_hybridly_core.NavigationResponse>;
}[];
executeInlineAction: (action: Action | string, record: RecordType | RecordIdentifier) => Promise<_hybridly_core.NavigationResponse>;
executeBulkAction: (action: Action | string, options?: BulkActionOptions) => Promise<_hybridly_core.NavigationResponse>;
columns: {
/** Toggles sorting for this column. */
toggleSort: (options?: ToggleSortOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
/** Checks whether the column is being sorted. */
isSorting: (direction?: SortDirection) => boolean;
/** Applies the filer for this column. */
applyFilter: (value: any, options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse | undefined>;
/** Clears the filter for this column. */
clearFilter: (options?: AvailableHybridRequestOptions) => Promise<_hybridly_core.NavigationResponse>;
/** Checks whether the column is sortable. */
isSortable: boolean;
/** Checks whether the column is filterable. */
isFilterable: boolean;
/** The name of this column. */
name: keyof RecordType;
/** The label of this column. */
label: string;
/** The type of this column. */
type: string;
/** Metadata of this column. */
metadata: Record<string, any>;
}[];
records: {
/** The actual record. */
record: any[];
/** The key of the record. Use this instead of `id`. */
key: RecordIdentifier;
/** Executes the given inline action. */
execute: (action: string | InlineAction) => Promise<_hybridly_core.NavigationResponse>;
/** Gets the available inline actions. */
actions: {
/** Executes the action. */
execute: () => Promise<_hybridly_core.NavigationResponse>;
/** The name of this action. */
name: string;
/** The label of this action. */
label: string;
/** The type of this action. */
type: string;
/** Custom metadata for this action. */
metadata: any;
}[];
/** Selects this record. */
select: () => void;
/** Deselects this record. */
deselect: () => void;
/** Toggles the selection for this record. */
toggle: (force?: boolean) => void;
/** Checks whether this record is selected. */
selected: boolean;
/** Gets the value of the record for the specified column. */
value: (column: string | Column<RecordType>) => any;
/** Gets the extra object of the record for the specified column. */
extra: (column: string | Column<RecordType>, path: string) => any;
}[];
paginator: Exclude<PaginatorKindName extends "cursor" ? CursorPaginator<RecordType> : PaginatorKindName extends "simple" ? SimplePaginator<RecordType> : Paginator<RecordType>, "data">;
};
/**
* Access reactive query parameters.
*
* @see https://hybridly.dev/api/utils/use-query-parameters.html
*/
declare function useQueryParameters<T extends Record<string, any> = Record<string, any>>(): T;
type RouteParameter = string | number | boolean | null | undefined;
type TransformFunction<V extends RouteParameter, R> = (val: V) => R;
type TransformType<T extends RouteParameter, O> = O extends {
transform: 'number';
} ? number : O extends {
transform: 'bool';
} ? boolean : O extends {
transform: 'string';
} ? string : O extends {
transform: 'date';
} ? Date : O extends {
transform: TransformFunction<T, infer R>;
} ? R : T;
interface UseQueryParameterOptions<V extends RouteParameter, R> {
/**
* Specifies a default value if the query parameter does not exist.
*/
defaultValue?: MaybeRefOrGetter<R>;
/**
* Transforms the query parameter.
*/
transform?: 'number' | 'bool' | 'string' | 'date' | TransformFunction<V, R>;
}
/**
* Makes the specified query parameter reactive.
*
* @see https://hybridly.dev/api/utils/use-query-parameter.html
*/
declare function useQueryParameter<ParameterType extends RouteParameter = RouteParameter, Options extends UseQueryParameterOptions<ParameterType, any> = UseQueryParameterOptions<ParameterType, ParameterType>>(name: string, options?: Options): Ref<TransformType<ParameterType, Options>>;
/**
* Initializes Hybridly's router and context.
*/
declare function initializeHybridly(options?: InitializeOptions): Promise<any>;
interface InitializeOptions {
/** Callback that gets executed before Vue is mounted. */
enhanceVue?: (
/** Vue application to enhance. */
vue: App<Element>,
/** Initial payload. */
payload: Record<string, any>) => any;
/** ID of the app element. */
id?: string;
/** Clean up the host element's payload dataset after loading. */
cleanup?: boolean;
/** Whether to set up the devtools plugin. */
devtools?: boolean;
/** Whether to display response error modals. */
responseErrorModals?: boolean;
/** Custom history state serialization functions. */
serializer?: RouterContextOptions['serializer'];
/** Progressbar options. */
progress?: false | Partial<ProgressOptions>;
/** Sets up the hybridly router. */
setup?: (options: SetupArguments) => any;
/** List of Hybridly plugins. */
plugins?: Plugin$1[];
/** Custom Axios instance. */
axios?: Axios;
/**
* Enables the View Transition API, if supported.
* @see https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition
*/
viewTransition?: boolean;
/** Options that will apply to all forms by default. Specific forms' options will override them. */
defaultFormOptions?: DefaultFormOptions;
}
interface SetupArguments {
/** DOM element to mount Vue on. */
element: Element;
/** Hybridly wrapper component. */
wrapper: any;
/** Hybridly wrapper component properties. */
props: {
context: RouterContext;
};
/** Vue plugin that registers the devtools. */
hybridly: Plugin;
/** Renders the wrapper. */
render: () => ReturnType<typeof h>;
/** Initial payload. */
payload: Record<string, any>;
}
declare const RouterLink: vue.DefineComponent<vue.ExtractPropTypes<{
href: {
type: StringConstructor;
required: false;
default: undefined;
};
as: {
type: (StringConstructor | ObjectConstructor)[];
default: string;
};
method: {
type: PropType<Method | Lowercase<Method>>;
default: string;
};
data: {
type: PropType<RequestData>;
default: () => {};
};
external: {
type: BooleanConstructor;
default: boolean;
};
disabled: {
type: BooleanConstructor;
default: boolean;
};
options: {
type: PropType<Omit<HybridRequestOptions, "url" | "data" | "method">>;
default: () => {};
};
text: {
type: StringConstructor;
required: false;
default: undefined;
};
preload: {
type: PropType<boolean | "hover" | "mount">;
default: boolean;
};
preserveScroll: {
type: BooleanConstructor;
default: undefined;
};
preserveState: {
type: BooleanConstructor;
default: undefined;
};
}>, (props: _vue_shared.LooseRequired<Readonly<vue.ExtractPropTypes<{
href: {
type: StringConstructor;
required: false;
default: undefined;
};
as: {
type: (StringConstructor | ObjectConstructor)[];
default: string;
};
method: {
type: PropType<Method | Lowercase<Method>>;
default: string;
};
data: {
type: PropType<RequestData>;
default: () => {};
};
external: {
type: BooleanConstructor;
default: boolean;
};
disabled: {
type: BooleanConstructor;
default: boolean;
};
options: {
type: PropType<Omit<HybridRequestOptions, "url" | "data" | "method">>;
default: () => {};
};
text: {
type: StringConstructor;
required: false;
default: undefined;
};
preload: {
type: PropType<boolean | "hover" | "mount">;
default: boolean;
};
preserveScroll: {
type: BooleanConstructor;
default: undefined;
};
preserveState: {
type: BooleanConstructor;
default: undefined;
};
}>> & Readonly<{}> & {}>) => vue.VNode<vue.RendererNode, vue.RendererElement, {
[key: string]: any;
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
href: {
type: StringConstructor;
required: false;
default: undefined;
};
as: {
type: (StringConstructor | ObjectConstructor)[];
default: string;
};
method: {
type: PropType<Method | Lowercase<Method>>;
default: string;
};
data: {
type: PropType<RequestData>;
default: () => {};
};
external: {
type: BooleanConstructor;
default: boolean;
};
disabled: {
type: BooleanConstructor;
default: boolean;
};
options: {
type: PropType<Omit<HybridRequestOptions, "url" | "data" | "method">>;
default: () => {};
};
text: {
type: StringConstructor;
required: false;
default: undefined;
};
preload: {
type: PropType<boolean | "hover" | "mount">;
default: boolean;
};
preserveScroll: {
type: BooleanConstructor;
default: undefined;
};
preserveState: {
type: BooleanConstructor;
default: undefined;
};
}>> & Readonly<{}>, {
data: RequestData;
method: "delete" | "get" | Method | "post" | "put" | "patch";
preserveScroll: boolean;
preserveState: boolean;
href: string;
as: string | Record<string, any>;
external: boolean;
disabled: boolean;
options: Omit<HybridRequestOptions, "data" | "url" | "method">;
text: string;
preload: boolean | "hover" | "mount";
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
export { RouterLink, initializeHybridly, registerHook, setProperty, useBackForward, useBulkSelect, useDialog, useForm, useHistoryState, useProperties, useProperty, useQueryParameter, useQueryParameters, useRefinements, useRoute, useTable };
export type { Action, AvailableHybridRequestOptions, BindFilterOptions, BulkAction, BulkSelection, Column, DefaultFormOptions, InitializeOptions, InlineAction, RecordIdentifier, SortDirection, TableDefaultOptions, ToggleSortOptions };