@hybridly/vue 0.0.1-alpha.6 → 0.0.1-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -18
- package/dist/index.d.ts +37 -41
- package/dist/index.mjs +14 -18
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -9,13 +9,11 @@ const progressPlugin = require('@hybridly/progress-plugin');
|
|
|
9
9
|
const devtoolsApi = require('@vue/devtools-api');
|
|
10
10
|
const qs = require('qs');
|
|
11
11
|
const isEqual = require('lodash.isequal');
|
|
12
|
-
const clone = require('lodash.clonedeep');
|
|
13
12
|
|
|
14
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
15
14
|
|
|
16
15
|
const qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
|
|
17
16
|
const isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
18
|
-
const clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
|
|
19
17
|
|
|
20
18
|
const state = {
|
|
21
19
|
context: vue.ref(),
|
|
@@ -192,7 +190,7 @@ function setupDevtools(app) {
|
|
|
192
190
|
const listen = [
|
|
193
191
|
"start",
|
|
194
192
|
"data",
|
|
195
|
-
"
|
|
193
|
+
"navigated",
|
|
196
194
|
"progress",
|
|
197
195
|
"error",
|
|
198
196
|
"abort",
|
|
@@ -213,7 +211,7 @@ function setupDevtools(app) {
|
|
|
213
211
|
data: options
|
|
214
212
|
}
|
|
215
213
|
});
|
|
216
|
-
listen.forEach((event) => core.
|
|
214
|
+
listen.forEach((event) => core.registerHook(event, (data) => {
|
|
217
215
|
api.addTimelineEvent({
|
|
218
216
|
layerId: hybridlyEventsTimelineLayerId,
|
|
219
217
|
event: {
|
|
@@ -229,7 +227,7 @@ function setupDevtools(app) {
|
|
|
229
227
|
api.notifyComponentUpdate();
|
|
230
228
|
}, 100);
|
|
231
229
|
}
|
|
232
|
-
}));
|
|
230
|
+
}, { once: true }));
|
|
233
231
|
});
|
|
234
232
|
});
|
|
235
233
|
}
|
|
@@ -303,7 +301,9 @@ function prepare(options) {
|
|
|
303
301
|
if (routes) {
|
|
304
302
|
state.setRoutes(window.hybridly?.routes);
|
|
305
303
|
window.addEventListener("hybridly:routes", (event) => {
|
|
306
|
-
|
|
304
|
+
if (event.detail) {
|
|
305
|
+
state.setRoutes(event.detail);
|
|
306
|
+
}
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
}
|
|
@@ -371,7 +371,7 @@ Please specify a more appropriate element using the "as" attribute. For example:
|
|
|
371
371
|
if (props.disabled) {
|
|
372
372
|
return;
|
|
373
373
|
}
|
|
374
|
-
core.router.
|
|
374
|
+
core.router.navigate({
|
|
375
375
|
url,
|
|
376
376
|
data,
|
|
377
377
|
method,
|
|
@@ -434,7 +434,6 @@ const HybridlyImports = {
|
|
|
434
434
|
],
|
|
435
435
|
"hybridly": [
|
|
436
436
|
"registerHook",
|
|
437
|
-
"registerHookOnce",
|
|
438
437
|
"router",
|
|
439
438
|
"can"
|
|
440
439
|
]
|
|
@@ -505,12 +504,8 @@ function useContext() {
|
|
|
505
504
|
return vue.computed(() => state.context.value);
|
|
506
505
|
}
|
|
507
506
|
|
|
508
|
-
function useRouter() {
|
|
509
|
-
return core.router;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
507
|
function safeClone(obj) {
|
|
513
|
-
return
|
|
508
|
+
return utils.clone(vue.toRaw(obj));
|
|
514
509
|
}
|
|
515
510
|
function useForm(options) {
|
|
516
511
|
const shouldRemember = options?.key !== false;
|
|
@@ -541,7 +536,7 @@ function useForm(options) {
|
|
|
541
536
|
function submit(optionsOverrides) {
|
|
542
537
|
const url = typeof options.url === "function" ? options.url() : options.url;
|
|
543
538
|
const data = typeof options.transform === "function" ? options.transform?.(fields) : fields;
|
|
544
|
-
return core.router.
|
|
539
|
+
return core.router.navigate({
|
|
545
540
|
...options,
|
|
546
541
|
url: url ?? state.context.value?.url,
|
|
547
542
|
method: options.method ?? "POST",
|
|
@@ -549,14 +544,14 @@ function useForm(options) {
|
|
|
549
544
|
data: safeClone(data),
|
|
550
545
|
preserveState: optionsOverrides?.preserveState === void 0 && options.method !== "GET" ? true : optionsOverrides?.preserveState,
|
|
551
546
|
hooks: {
|
|
552
|
-
before: (
|
|
547
|
+
before: (navigation) => {
|
|
553
548
|
failed.value = false;
|
|
554
549
|
successful.value = false;
|
|
555
550
|
recentlySuccessful.value = false;
|
|
556
551
|
clearTimeout(timeoutIds.recentlySuccessful);
|
|
557
552
|
clearTimeout(timeoutIds.recentlyFailed);
|
|
558
553
|
clearErrors();
|
|
559
|
-
return options.hooks?.before?.(
|
|
554
|
+
return options.hooks?.before?.(navigation);
|
|
560
555
|
},
|
|
561
556
|
start: (context) => {
|
|
562
557
|
processing.value = true;
|
|
@@ -640,7 +635,7 @@ function useHistoryState(key, initial) {
|
|
|
640
635
|
|
|
641
636
|
function useBackForward() {
|
|
642
637
|
const callbacks = [];
|
|
643
|
-
core.registerHook("
|
|
638
|
+
core.registerHook("navigated", (options) => {
|
|
644
639
|
if (options.isBackForward) {
|
|
645
640
|
callbacks.forEach((fn) => fn(state.context.value));
|
|
646
641
|
callbacks.splice(0, callbacks.length);
|
|
@@ -835,4 +830,3 @@ exports.useHistoryState = useHistoryState;
|
|
|
835
830
|
exports.usePaginator = usePaginator;
|
|
836
831
|
exports.useProperties = useProperties;
|
|
837
832
|
exports.useProperty = useProperty;
|
|
838
|
-
exports.useRouter = useRouter;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { Plugin as Plugin$2, h, PropType, ComputedRef, DeepReadonly } from 'vue';
|
|
3
3
|
import * as _hybridly_core from '@hybridly/core';
|
|
4
|
-
import {
|
|
4
|
+
import { HybridPayload as HybridPayload$1, ResolveComponent as ResolveComponent$1, RouterContextOptions, Plugin as Plugin$1, RouterContext, Method as Method$1, HybridRequestOptions as HybridRequestOptions$1, UrlResolvable as UrlResolvable$1 } from '@hybridly/core';
|
|
5
5
|
export { can, router } from '@hybridly/core';
|
|
6
6
|
import { ProgressOptions } from '@hybridly/progress-plugin';
|
|
7
7
|
import * as _vue_shared from '@vue/shared';
|
|
@@ -13,7 +13,7 @@ interface HybridlyOptions {
|
|
|
13
13
|
/** ID of the app element. */
|
|
14
14
|
id?: string;
|
|
15
15
|
/** Initial view data. */
|
|
16
|
-
payload?:
|
|
16
|
+
payload?: HybridPayload$1;
|
|
17
17
|
/** A collection of pages. */
|
|
18
18
|
pages?: Record<string, any>;
|
|
19
19
|
/** An optional default persistent layout. */
|
|
@@ -72,7 +72,7 @@ declare const RouterLink: vue.DefineComponent<{
|
|
|
72
72
|
default: boolean;
|
|
73
73
|
};
|
|
74
74
|
options: {
|
|
75
|
-
type: PropType<Omit<
|
|
75
|
+
type: PropType<Omit<HybridRequestOptions$1, "url" | "data" | "method">>;
|
|
76
76
|
default: () => {};
|
|
77
77
|
};
|
|
78
78
|
}, (props: Readonly<_vue_shared.LooseRequired<Readonly<vue.ExtractPropTypes<{
|
|
@@ -101,7 +101,7 @@ declare const RouterLink: vue.DefineComponent<{
|
|
|
101
101
|
default: boolean;
|
|
102
102
|
};
|
|
103
103
|
options: {
|
|
104
|
-
type: PropType<Omit<
|
|
104
|
+
type: PropType<Omit<HybridRequestOptions$1, "url" | "data" | "method">>;
|
|
105
105
|
default: () => {};
|
|
106
106
|
};
|
|
107
107
|
}>> & {}>>) => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
@@ -132,13 +132,13 @@ declare const RouterLink: vue.DefineComponent<{
|
|
|
132
132
|
default: boolean;
|
|
133
133
|
};
|
|
134
134
|
options: {
|
|
135
|
-
type: PropType<Omit<
|
|
135
|
+
type: PropType<Omit<HybridRequestOptions$1, "url" | "data" | "method">>;
|
|
136
136
|
default: () => {};
|
|
137
137
|
};
|
|
138
138
|
}>>, {
|
|
139
139
|
data: RequestData;
|
|
140
140
|
method: Method$1 | "get" | "delete" | "post" | "put" | "patch";
|
|
141
|
-
options: Omit<
|
|
141
|
+
options: Omit<HybridRequestOptions$1, "url" | "data" | "method">;
|
|
142
142
|
as: string | Record<string, any>;
|
|
143
143
|
external: boolean;
|
|
144
144
|
disabled: boolean;
|
|
@@ -184,11 +184,11 @@ declare type MaybePromise<T> = T | Promise<T>;
|
|
|
184
184
|
|
|
185
185
|
interface Hooks {
|
|
186
186
|
/**
|
|
187
|
-
* Called before anything when a
|
|
187
|
+
* Called before anything when a navigation is going to happen.
|
|
188
188
|
*/
|
|
189
|
-
before: (options:
|
|
189
|
+
before: (options: HybridRequestOptions) => MaybePromise<any | boolean>;
|
|
190
190
|
/**
|
|
191
|
-
* Called before the request of a
|
|
191
|
+
* Called before the request of a navigation is going to happen.
|
|
192
192
|
*/
|
|
193
193
|
start: (context: InternalRouterContext) => MaybePromise<any>;
|
|
194
194
|
/**
|
|
@@ -196,13 +196,13 @@ interface Hooks {
|
|
|
196
196
|
*/
|
|
197
197
|
progress: (progress: Progress) => MaybePromise<any>;
|
|
198
198
|
/**
|
|
199
|
-
* Called when data is received after a request for a
|
|
199
|
+
* Called when data is received after a request for a navigation.
|
|
200
200
|
*/
|
|
201
201
|
data: (response: AxiosResponse) => MaybePromise<any>;
|
|
202
202
|
/**
|
|
203
203
|
* Called when a request is successful and there is no error.
|
|
204
204
|
*/
|
|
205
|
-
success: (payload:
|
|
205
|
+
success: (payload: HybridPayload) => MaybePromise<any>;
|
|
206
206
|
/**
|
|
207
207
|
* Called when a request is successful but there were errors.
|
|
208
208
|
*/
|
|
@@ -228,18 +228,18 @@ interface Hooks {
|
|
|
228
228
|
*/
|
|
229
229
|
after: (context: InternalRouterContext) => MaybePromise<void>;
|
|
230
230
|
/**
|
|
231
|
-
* Called when a
|
|
231
|
+
* Called when a navigation has been made and a page component has been navigated to.
|
|
232
232
|
*/
|
|
233
|
-
|
|
233
|
+
navigated: (options: NavigationOptions) => MaybePromise<void>;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
declare type UrlResolvable = string | URL | Location;
|
|
237
237
|
declare type UrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toString'>>;
|
|
238
238
|
|
|
239
|
-
declare type ConditionalNavigationOption = boolean | ((payload:
|
|
239
|
+
declare type ConditionalNavigationOption = boolean | ((payload: HybridPayload) => boolean);
|
|
240
240
|
interface NavigationOptions {
|
|
241
241
|
/** View to navigate to. */
|
|
242
|
-
payload?:
|
|
242
|
+
payload?: HybridPayload;
|
|
243
243
|
/**
|
|
244
244
|
* Whether to replace the current history state instead of adding
|
|
245
245
|
* one. This affects the browser's "back" and "forward" features.
|
|
@@ -267,41 +267,41 @@ interface NavigationOptions {
|
|
|
267
267
|
*/
|
|
268
268
|
updateHistoryState?: boolean;
|
|
269
269
|
/**
|
|
270
|
-
* Defines whether this navigation is a back/forward
|
|
270
|
+
* Defines whether this navigation is a back/forward navigation from the popstate event.
|
|
271
271
|
* @internal This is an advanced property meant to be used internally.
|
|
272
272
|
*/
|
|
273
273
|
isBackForward?: boolean;
|
|
274
274
|
}
|
|
275
275
|
declare type Method = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
276
|
-
interface
|
|
277
|
-
/** The URL to
|
|
276
|
+
interface HybridRequestOptions extends Omit<NavigationOptions, 'payload'> {
|
|
277
|
+
/** The URL to navigation. */
|
|
278
278
|
url?: UrlResolvable;
|
|
279
279
|
/** HTTP verb to use for the request. */
|
|
280
280
|
method?: Method;
|
|
281
281
|
/** Body of the request. */
|
|
282
282
|
data?: RequestData;
|
|
283
|
-
/** Which properties to update for this
|
|
283
|
+
/** Which properties to update for this navigation. Other properties will be ignored. */
|
|
284
284
|
only?: string | string[];
|
|
285
|
-
/** Which properties not to update for this
|
|
285
|
+
/** Which properties not to update for this navigation. Other properties will be updated. */
|
|
286
286
|
except?: string | string[];
|
|
287
287
|
/** Specific headers to add to the request. */
|
|
288
288
|
headers?: Record<string, string>;
|
|
289
289
|
/** The bag in which to put potential errors. */
|
|
290
290
|
errorBag?: string;
|
|
291
|
-
/** Hooks for this
|
|
291
|
+
/** Hooks for this navigation. */
|
|
292
292
|
hooks?: Partial<Hooks>;
|
|
293
293
|
/** If `true`, force the usage of a `FormData` object. */
|
|
294
294
|
useFormData?: boolean;
|
|
295
295
|
}
|
|
296
|
-
/**
|
|
297
|
-
interface
|
|
296
|
+
/** A navigation being made. */
|
|
297
|
+
interface PendingNavigation {
|
|
298
298
|
/** The URL to which the request is being made. */
|
|
299
299
|
url: URL;
|
|
300
300
|
/** Abort controller associated to this request. */
|
|
301
301
|
controller: AbortController;
|
|
302
|
-
/** Options for the associated
|
|
303
|
-
options:
|
|
304
|
-
/**
|
|
302
|
+
/** Options for the associated hybrid request. */
|
|
303
|
+
options: HybridRequestOptions;
|
|
304
|
+
/** Navigation identifier. */
|
|
305
305
|
id: string;
|
|
306
306
|
}
|
|
307
307
|
/** A page or dialog component. */
|
|
@@ -326,8 +326,8 @@ declare type DialogComponent = any;
|
|
|
326
326
|
declare type ResolveComponent = (name: string) => Promise<ViewComponent>;
|
|
327
327
|
declare type SwapView = (options: SwapOptions<ViewComponent>) => Promise<void>;
|
|
328
328
|
declare type SwapDialog = (options: SwapOptions<DialogComponent>) => Promise<void>;
|
|
329
|
-
/** The payload of a
|
|
330
|
-
interface
|
|
329
|
+
/** The payload of a navigation request from the server. */
|
|
330
|
+
interface HybridPayload {
|
|
331
331
|
/** The view to use in this request. */
|
|
332
332
|
view: View;
|
|
333
333
|
/** An optional dialog. */
|
|
@@ -347,10 +347,9 @@ interface Errors {
|
|
|
347
347
|
[key: string]: string;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
interface Plugin {
|
|
350
|
+
interface Plugin extends Partial<Hooks> {
|
|
351
351
|
name: string;
|
|
352
|
-
initialized
|
|
353
|
-
hooks: Partial<Hooks>;
|
|
352
|
+
initialized?: (context: InternalRouterContext) => MaybePromise<void>;
|
|
354
353
|
}
|
|
355
354
|
|
|
356
355
|
/** Router context. */
|
|
@@ -369,8 +368,8 @@ interface InternalRouterContext {
|
|
|
369
368
|
scrollRegions: ScrollRegion[];
|
|
370
369
|
/** Arbitrary state. */
|
|
371
370
|
state: Record<string, any>;
|
|
372
|
-
/** Currently pending
|
|
373
|
-
|
|
371
|
+
/** Currently pending navigation. */
|
|
372
|
+
pendingNavigation?: PendingNavigation;
|
|
374
373
|
/** History state serializer. */
|
|
375
374
|
serializer: Serializer;
|
|
376
375
|
/** List of plugins. */
|
|
@@ -402,11 +401,8 @@ interface Serializer {
|
|
|
402
401
|
/** Accesses the hybridly context. */
|
|
403
402
|
declare function useContext(): vue.ComputedRef<Readonly<InternalRouterContext> | undefined>;
|
|
404
403
|
|
|
405
|
-
/** Gets the router. */
|
|
406
|
-
declare function useRouter(): _hybridly_core.Router;
|
|
407
|
-
|
|
408
404
|
declare type Fields = Record<string, any>;
|
|
409
|
-
interface FormOptions<T extends Fields> extends Omit<
|
|
405
|
+
interface FormOptions<T extends Fields> extends Omit<HybridRequestOptions$1, 'data' | 'url'> {
|
|
410
406
|
fields: T;
|
|
411
407
|
url?: UrlResolvable$1 | (() => UrlResolvable$1);
|
|
412
408
|
key?: string | false;
|
|
@@ -420,8 +416,8 @@ declare function useForm<T extends Fields = Fields>(options: FormOptions<T>): {
|
|
|
420
416
|
abort: () => void;
|
|
421
417
|
setErrors: (incoming: Record<string, string>) => void;
|
|
422
418
|
clearErrors: () => void;
|
|
423
|
-
submitWithOptions: (optionsOverrides?: Omit<
|
|
424
|
-
submit: () => Promise<_hybridly_core.
|
|
419
|
+
submitWithOptions: (optionsOverrides?: Omit<HybridRequestOptions$1, 'data'>) => Promise<_hybridly_core.NavigationResponse>;
|
|
420
|
+
submit: () => Promise<_hybridly_core.NavigationResponse>;
|
|
425
421
|
hasErrors: boolean;
|
|
426
422
|
initial: vue.UnwrapRef<DeepReadonly<T>>;
|
|
427
423
|
loaded: any;
|
|
@@ -456,7 +452,7 @@ declare function useHistoryState<T = any>(key: string, initial: T): vue.Ref<vue.
|
|
|
456
452
|
declare type BackForwardCallback = (context: RouterContext) => void;
|
|
457
453
|
declare function useBackForward(): {
|
|
458
454
|
onBackForward: (fn: BackForwardCallback) => void;
|
|
459
|
-
reloadOnBackForward: (options?:
|
|
455
|
+
reloadOnBackForward: (options?: HybridRequestOptions$1) => void;
|
|
460
456
|
};
|
|
461
457
|
|
|
462
458
|
declare global {
|
|
@@ -571,4 +567,4 @@ declare type RouteParameters<T extends RouteName> = Record<keyof GlobalRouteColl
|
|
|
571
567
|
*/
|
|
572
568
|
declare function route<T extends RouteName>(name: T, parameters?: RouteParameters<T>, absolute?: boolean): string;
|
|
573
569
|
|
|
574
|
-
export { AutoImportResolverOptions, GlobalRouteCollection, HybridlyImports, HybridlyResolver, Layout, RouteCollection, RouteDefinition, RouteName, RouteParameters, RouterConfiguration, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, route, useBackForward, useContext, useForm, useHistoryState, usePaginator, useProperties, useProperty
|
|
570
|
+
export { AutoImportResolverOptions, GlobalRouteCollection, HybridlyImports, HybridlyResolver, Layout, RouteCollection, RouteDefinition, RouteName, RouteParameters, RouterConfiguration, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, route, useBackForward, useContext, useForm, useHistoryState, usePaginator, useProperties, useProperty };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ref, shallowRef, unref, triggerRef, defineComponent, h, isRef, reactive, readonly, computed, watch, toRaw } from 'vue';
|
|
2
|
-
import { registerHook,
|
|
2
|
+
import { registerHook, createRouter, makeUrl, router } from '@hybridly/core';
|
|
3
3
|
export { can, router } from '@hybridly/core';
|
|
4
|
-
import { debug, showPageComponentErrorModal, merge } from '@hybridly/utils';
|
|
4
|
+
import { debug, showPageComponentErrorModal, merge, clone } from '@hybridly/utils';
|
|
5
5
|
import { progress } from '@hybridly/progress-plugin';
|
|
6
6
|
import { setupDevtoolsPlugin } from '@vue/devtools-api';
|
|
7
7
|
import qs, { parse, stringify } from 'qs';
|
|
8
8
|
import isEqual from 'lodash.isequal';
|
|
9
|
-
import clone from 'lodash.clonedeep';
|
|
10
9
|
|
|
11
10
|
const state = {
|
|
12
11
|
context: ref(),
|
|
@@ -183,7 +182,7 @@ function setupDevtools(app) {
|
|
|
183
182
|
const listen = [
|
|
184
183
|
"start",
|
|
185
184
|
"data",
|
|
186
|
-
"
|
|
185
|
+
"navigated",
|
|
187
186
|
"progress",
|
|
188
187
|
"error",
|
|
189
188
|
"abort",
|
|
@@ -204,7 +203,7 @@ function setupDevtools(app) {
|
|
|
204
203
|
data: options
|
|
205
204
|
}
|
|
206
205
|
});
|
|
207
|
-
listen.forEach((event) =>
|
|
206
|
+
listen.forEach((event) => registerHook(event, (data) => {
|
|
208
207
|
api.addTimelineEvent({
|
|
209
208
|
layerId: hybridlyEventsTimelineLayerId,
|
|
210
209
|
event: {
|
|
@@ -220,7 +219,7 @@ function setupDevtools(app) {
|
|
|
220
219
|
api.notifyComponentUpdate();
|
|
221
220
|
}, 100);
|
|
222
221
|
}
|
|
223
|
-
}));
|
|
222
|
+
}, { once: true }));
|
|
224
223
|
});
|
|
225
224
|
});
|
|
226
225
|
}
|
|
@@ -294,7 +293,9 @@ function prepare(options) {
|
|
|
294
293
|
if (routes) {
|
|
295
294
|
state.setRoutes(window.hybridly?.routes);
|
|
296
295
|
window.addEventListener("hybridly:routes", (event) => {
|
|
297
|
-
|
|
296
|
+
if (event.detail) {
|
|
297
|
+
state.setRoutes(event.detail);
|
|
298
|
+
}
|
|
298
299
|
});
|
|
299
300
|
}
|
|
300
301
|
}
|
|
@@ -362,7 +363,7 @@ Please specify a more appropriate element using the "as" attribute. For example:
|
|
|
362
363
|
if (props.disabled) {
|
|
363
364
|
return;
|
|
364
365
|
}
|
|
365
|
-
router.
|
|
366
|
+
router.navigate({
|
|
366
367
|
url,
|
|
367
368
|
data,
|
|
368
369
|
method,
|
|
@@ -425,7 +426,6 @@ const HybridlyImports = {
|
|
|
425
426
|
],
|
|
426
427
|
"hybridly": [
|
|
427
428
|
"registerHook",
|
|
428
|
-
"registerHookOnce",
|
|
429
429
|
"router",
|
|
430
430
|
"can"
|
|
431
431
|
]
|
|
@@ -496,10 +496,6 @@ function useContext() {
|
|
|
496
496
|
return computed(() => state.context.value);
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
function useRouter() {
|
|
500
|
-
return router;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
499
|
function safeClone(obj) {
|
|
504
500
|
return clone(toRaw(obj));
|
|
505
501
|
}
|
|
@@ -532,7 +528,7 @@ function useForm(options) {
|
|
|
532
528
|
function submit(optionsOverrides) {
|
|
533
529
|
const url = typeof options.url === "function" ? options.url() : options.url;
|
|
534
530
|
const data = typeof options.transform === "function" ? options.transform?.(fields) : fields;
|
|
535
|
-
return router.
|
|
531
|
+
return router.navigate({
|
|
536
532
|
...options,
|
|
537
533
|
url: url ?? state.context.value?.url,
|
|
538
534
|
method: options.method ?? "POST",
|
|
@@ -540,14 +536,14 @@ function useForm(options) {
|
|
|
540
536
|
data: safeClone(data),
|
|
541
537
|
preserveState: optionsOverrides?.preserveState === void 0 && options.method !== "GET" ? true : optionsOverrides?.preserveState,
|
|
542
538
|
hooks: {
|
|
543
|
-
before: (
|
|
539
|
+
before: (navigation) => {
|
|
544
540
|
failed.value = false;
|
|
545
541
|
successful.value = false;
|
|
546
542
|
recentlySuccessful.value = false;
|
|
547
543
|
clearTimeout(timeoutIds.recentlySuccessful);
|
|
548
544
|
clearTimeout(timeoutIds.recentlyFailed);
|
|
549
545
|
clearErrors();
|
|
550
|
-
return options.hooks?.before?.(
|
|
546
|
+
return options.hooks?.before?.(navigation);
|
|
551
547
|
},
|
|
552
548
|
start: (context) => {
|
|
553
549
|
processing.value = true;
|
|
@@ -631,7 +627,7 @@ function useHistoryState(key, initial) {
|
|
|
631
627
|
|
|
632
628
|
function useBackForward() {
|
|
633
629
|
const callbacks = [];
|
|
634
|
-
registerHook("
|
|
630
|
+
registerHook("navigated", (options) => {
|
|
635
631
|
if (options.isBackForward) {
|
|
636
632
|
callbacks.forEach((fn) => fn(state.context.value));
|
|
637
633
|
callbacks.splice(0, callbacks.length);
|
|
@@ -810,4 +806,4 @@ function route(name, parameters, absolute) {
|
|
|
810
806
|
return new Router(name, parameters, absolute).toString();
|
|
811
807
|
}
|
|
812
808
|
|
|
813
|
-
export { HybridlyImports, HybridlyResolver, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, route, useBackForward, useContext, useForm, useHistoryState, usePaginator, useProperties, useProperty
|
|
809
|
+
export { HybridlyImports, HybridlyResolver, RouterLink, defineLayout, defineLayoutProperties, initializeHybridly, route, useBackForward, useContext, useForm, useHistoryState, usePaginator, useProperties, useProperty };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybridly/vue",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.7",
|
|
4
4
|
"description": "A solution to develop server-driven, client-rendered applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hybridly",
|
|
@@ -38,12 +38,11 @@
|
|
|
38
38
|
"vue": "^3.2.37"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@hybridly/core": "0.0.1-alpha.
|
|
42
|
-
"@hybridly/progress-plugin": "0.0.1-alpha.
|
|
43
|
-
"@hybridly/utils": "0.0.1-alpha.
|
|
41
|
+
"@hybridly/core": "0.0.1-alpha.7",
|
|
42
|
+
"@hybridly/progress-plugin": "0.0.1-alpha.7",
|
|
43
|
+
"@hybridly/utils": "0.0.1-alpha.7",
|
|
44
44
|
"@vue/devtools-api": "^6.4.4",
|
|
45
45
|
"defu": "^6.1.0",
|
|
46
|
-
"lodash.clonedeep": "^4.5.0",
|
|
47
46
|
"lodash.isequal": "^4.5.0",
|
|
48
47
|
"nprogress": "^0.2.0",
|
|
49
48
|
"qs": "^6.11.0"
|