@simonbackx/vue-app-navigation 2.4.2 → 2.5.1
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.js +34 -7
- package/dist/src/ComponentWithProperties.d.ts +3 -1
- package/dist/src/HistoryManager.d.ts +7 -2
- package/dist/src/ModalMixin.d.ts +8 -4
- package/dist/src/ModalStackComponent.vue.d.ts +4 -2
- package/dist/src/StackComponent.vue.d.ts +2 -1
- package/dist/src/utils/navigationHooks.d.ts +3 -0
- package/dist/test/EditWebshopMixin.d.ts +9 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -276,6 +276,16 @@ class HistoryManagerStatic {
|
|
|
276
276
|
});
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
|
+
resolveUrl(url, index) {
|
|
280
|
+
if (url !== null) {
|
|
281
|
+
return "/" + UrlHelper.trim(UrlHelper.transformUrl(url));
|
|
282
|
+
}
|
|
283
|
+
if (!this.states[index - 1]) {
|
|
284
|
+
return "/" + UrlHelper.trim(UrlHelper.transformUrl("/"));
|
|
285
|
+
}
|
|
286
|
+
const previousUrl = this.states[index - 1].url;
|
|
287
|
+
return this.resolveUrl(previousUrl ?? null, index - 1);
|
|
288
|
+
}
|
|
279
289
|
/// Set the current URL without modifying states
|
|
280
290
|
setUrl(url, title, index) {
|
|
281
291
|
if (!this.active) {
|
|
@@ -302,7 +312,7 @@ class HistoryManagerStatic {
|
|
|
302
312
|
if (ComponentWithProperties.debug) {
|
|
303
313
|
console.log("history.replaceState", count, url);
|
|
304
314
|
}
|
|
305
|
-
const formattedUrl =
|
|
315
|
+
const formattedUrl = this.resolveUrl(url, count);
|
|
306
316
|
history.replaceState({ counter: count }, "", formattedUrl);
|
|
307
317
|
if (state.title) {
|
|
308
318
|
window.document.title = this.formatTitle(state.title);
|
|
@@ -343,12 +353,8 @@ class HistoryManagerStatic {
|
|
|
343
353
|
if (ComponentWithProperties.debug) {
|
|
344
354
|
console.log("history.replaceState - updateUrl");
|
|
345
355
|
}
|
|
346
|
-
const
|
|
347
|
-
const formattedUrl =
|
|
348
|
-
UrlHelper.transformUrl(
|
|
349
|
-
current.getPath()
|
|
350
|
-
)
|
|
351
|
-
);
|
|
356
|
+
const lastState = this.states[this.states.length - 1];
|
|
357
|
+
const formattedUrl = this.resolveUrl(lastState.url ?? null, lastState.index);
|
|
352
358
|
history.replaceState({ counter: this.counter }, "", formattedUrl);
|
|
353
359
|
});
|
|
354
360
|
}
|
|
@@ -705,6 +711,10 @@ const _ComponentWithProperties = class _ComponentWithProperties {
|
|
|
705
711
|
ownsHistoryIndex() {
|
|
706
712
|
return this.historyIndex !== null && _ComponentWithProperties.historyIndexOwners.get(this.historyIndex) === this;
|
|
707
713
|
}
|
|
714
|
+
overrideUrl(url, title) {
|
|
715
|
+
this.provide.reactive_navigation_url = url;
|
|
716
|
+
this.setUrl(url, title);
|
|
717
|
+
}
|
|
708
718
|
setUrl(url, title) {
|
|
709
719
|
if (this.historyIndex === null) {
|
|
710
720
|
if (_ComponentWithProperties.debug)
|
|
@@ -2146,6 +2156,12 @@ function setTitle(title) {
|
|
|
2146
2156
|
urlHelpers.setTitle(title);
|
|
2147
2157
|
});
|
|
2148
2158
|
}
|
|
2159
|
+
function setUrl(url, title) {
|
|
2160
|
+
const urlHelpers = useUrl();
|
|
2161
|
+
onMounted(() => {
|
|
2162
|
+
urlHelpers.overrideUrl(url, title);
|
|
2163
|
+
});
|
|
2164
|
+
}
|
|
2149
2165
|
function useUrl() {
|
|
2150
2166
|
const currentComponent = useCurrentComponent();
|
|
2151
2167
|
const navigationUrl = inject("reactive_navigation_url", null);
|
|
@@ -2184,6 +2200,16 @@ function useUrl() {
|
|
|
2184
2200
|
matchCurrent(template, params) {
|
|
2185
2201
|
const helper = new UrlHelper(void 0, this.getUrl());
|
|
2186
2202
|
return helper.match(template, params);
|
|
2203
|
+
},
|
|
2204
|
+
overrideUrl(url, title) {
|
|
2205
|
+
if (!currentComponent) {
|
|
2206
|
+
console.error("No current component while setting title", title);
|
|
2207
|
+
return;
|
|
2208
|
+
}
|
|
2209
|
+
if (unref(disableUrl)) {
|
|
2210
|
+
return;
|
|
2211
|
+
}
|
|
2212
|
+
currentComponent == null ? void 0 : currentComponent.overrideUrl(url, title);
|
|
2187
2213
|
}
|
|
2188
2214
|
};
|
|
2189
2215
|
}
|
|
@@ -2946,6 +2972,7 @@ export {
|
|
|
2946
2972
|
onNotCheckRoutes,
|
|
2947
2973
|
setTitle,
|
|
2948
2974
|
setTitleSuffix,
|
|
2975
|
+
setUrl,
|
|
2949
2976
|
templateToUrl,
|
|
2950
2977
|
useCanDismiss,
|
|
2951
2978
|
useCanPop,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HistoryUrl } from './HistoryManager';
|
|
1
2
|
import { ComponentPublicInstance, VNode } from 'vue';
|
|
2
3
|
|
|
3
4
|
export type ModalDisplayStyle = "cover" | "popup" | "overlay" | "sheet" | "side-view";
|
|
@@ -46,7 +47,8 @@ export declare class ComponentWithProperties {
|
|
|
46
47
|
assignHistoryIndex(): void;
|
|
47
48
|
inheritHistoryIndex(index: number): void;
|
|
48
49
|
ownsHistoryIndex(): boolean;
|
|
49
|
-
|
|
50
|
+
overrideUrl(url: HistoryUrl, title?: string): void;
|
|
51
|
+
setUrl(url: HistoryUrl, title?: string): void;
|
|
50
52
|
setTitle(title: string): void;
|
|
51
53
|
/**
|
|
52
54
|
* This will get called when the user returned to this component
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* null makes sure the previous URL is used for this route
|
|
4
|
+
*/
|
|
5
|
+
export type HistoryUrl = string | null;
|
|
2
6
|
type HistoryState = {
|
|
3
|
-
url?:
|
|
7
|
+
url?: HistoryUrl;
|
|
4
8
|
title?: string;
|
|
5
9
|
index: number;
|
|
6
10
|
adjustHistory: boolean;
|
|
@@ -26,7 +30,8 @@ declare class HistoryManagerStatic {
|
|
|
26
30
|
private addToQueue;
|
|
27
31
|
private runQueue;
|
|
28
32
|
private go;
|
|
29
|
-
|
|
33
|
+
resolveUrl(url: HistoryUrl, index: number): string;
|
|
34
|
+
setUrl(url: HistoryUrl, title?: string, index?: number): void;
|
|
30
35
|
updateUrl(): void;
|
|
31
36
|
formatTitle(title: string): string;
|
|
32
37
|
/**
|
package/dist/src/ModalMixin.d.ts
CHANGED
|
@@ -66,7 +66,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
66
66
|
assignHistoryIndex: () => void;
|
|
67
67
|
inheritHistoryIndex: (index: number) => void;
|
|
68
68
|
ownsHistoryIndex: () => boolean;
|
|
69
|
-
|
|
69
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
70
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
70
71
|
setTitle: (title: string) => void;
|
|
71
72
|
returnToHistoryIndex: () => boolean;
|
|
72
73
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -136,7 +137,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
136
137
|
assignHistoryIndex: () => void;
|
|
137
138
|
inheritHistoryIndex: (index: number) => void;
|
|
138
139
|
ownsHistoryIndex: () => boolean;
|
|
139
|
-
|
|
140
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
141
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
140
142
|
setTitle: (title: string) => void;
|
|
141
143
|
returnToHistoryIndex: () => boolean;
|
|
142
144
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -440,7 +442,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
440
442
|
assignHistoryIndex: () => void;
|
|
441
443
|
inheritHistoryIndex: (index: number) => void;
|
|
442
444
|
ownsHistoryIndex: () => boolean;
|
|
443
|
-
|
|
445
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
446
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
444
447
|
setTitle: (title: string) => void;
|
|
445
448
|
returnToHistoryIndex: () => boolean;
|
|
446
449
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -510,7 +513,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
510
513
|
assignHistoryIndex: () => void;
|
|
511
514
|
inheritHistoryIndex: (index: number) => void;
|
|
512
515
|
ownsHistoryIndex: () => boolean;
|
|
513
|
-
|
|
516
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
517
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
514
518
|
setTitle: (title: string) => void;
|
|
515
519
|
returnToHistoryIndex: () => boolean;
|
|
516
520
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -65,7 +65,8 @@ declare const ModalStackComponent: import('vue').DefineComponent<{
|
|
|
65
65
|
assignHistoryIndex: () => void;
|
|
66
66
|
inheritHistoryIndex: (index: number) => void;
|
|
67
67
|
ownsHistoryIndex: () => boolean;
|
|
68
|
-
|
|
68
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
69
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
69
70
|
setTitle: (title: string) => void;
|
|
70
71
|
returnToHistoryIndex: () => boolean;
|
|
71
72
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -135,7 +136,8 @@ declare const ModalStackComponent: import('vue').DefineComponent<{
|
|
|
135
136
|
assignHistoryIndex: () => void;
|
|
136
137
|
inheritHistoryIndex: (index: number) => void;
|
|
137
138
|
ownsHistoryIndex: () => boolean;
|
|
138
|
-
|
|
139
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
140
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
139
141
|
setTitle: (title: string) => void;
|
|
140
142
|
returnToHistoryIndex: () => boolean;
|
|
141
143
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -45,7 +45,8 @@ declare const StackComponent: import('vue').DefineComponent<{}, {}, {
|
|
|
45
45
|
assignHistoryIndex: () => void;
|
|
46
46
|
inheritHistoryIndex: (index: number) => void;
|
|
47
47
|
ownsHistoryIndex: () => boolean;
|
|
48
|
-
|
|
48
|
+
overrideUrl: (url: import('./HistoryManager.ts').HistoryUrl, title?: string | undefined) => void;
|
|
49
|
+
setUrl: (url: import('./HistoryManager.ts').HistoryUrl, title?: string | undefined) => void;
|
|
49
50
|
setTitle: (title: string) => void;
|
|
50
51
|
returnToHistoryIndex: () => boolean;
|
|
51
52
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UrlMatchResult, UrlParamsConstructors } from './UrlHelper';
|
|
2
2
|
import { PushOptions } from '../PushOptions';
|
|
3
3
|
import { PopOptions } from '../PopOptions';
|
|
4
|
+
import { HistoryUrl } from '../HistoryManager';
|
|
4
5
|
import { ComponentWithProperties } from '../ComponentWithProperties';
|
|
5
6
|
import { ComponentOptions, Ref } from 'vue';
|
|
6
7
|
|
|
@@ -86,6 +87,7 @@ export declare function useFocused(): boolean | Ref<boolean>;
|
|
|
86
87
|
export declare function extendUrl(url: string | Ref<string>): void;
|
|
87
88
|
export declare function setTitleSuffix(title: string): void;
|
|
88
89
|
export declare function setTitle(title: string): void;
|
|
90
|
+
export declare function setUrl(url: HistoryUrl, title?: string): void;
|
|
89
91
|
export declare function useUrl(): {
|
|
90
92
|
getUrl(): string;
|
|
91
93
|
/**
|
|
@@ -95,4 +97,5 @@ export declare function useUrl(): {
|
|
|
95
97
|
extendUrl(url: string): string;
|
|
96
98
|
match<Params>(template: string, params?: UrlParamsConstructors<Params>): UrlMatchResult<Params> | undefined;
|
|
97
99
|
matchCurrent<Params_1>(template: string, params?: UrlParamsConstructors<Params_1> | undefined): UrlMatchResult<Params_1> | undefined;
|
|
100
|
+
overrideUrl(url: HistoryUrl, title?: string): void;
|
|
98
101
|
};
|
|
@@ -129,7 +129,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
129
129
|
assignHistoryIndex: () => void;
|
|
130
130
|
inheritHistoryIndex: (index: number) => void;
|
|
131
131
|
ownsHistoryIndex: () => boolean;
|
|
132
|
-
|
|
132
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
133
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
133
134
|
setTitle: (title: string) => void;
|
|
134
135
|
returnToHistoryIndex: () => boolean;
|
|
135
136
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -199,7 +200,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
199
200
|
assignHistoryIndex: () => void;
|
|
200
201
|
inheritHistoryIndex: (index: number) => void;
|
|
201
202
|
ownsHistoryIndex: () => boolean;
|
|
202
|
-
|
|
203
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
204
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
203
205
|
setTitle: (title: string) => void;
|
|
204
206
|
returnToHistoryIndex: () => boolean;
|
|
205
207
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -503,7 +505,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
503
505
|
assignHistoryIndex: () => void;
|
|
504
506
|
inheritHistoryIndex: (index: number) => void;
|
|
505
507
|
ownsHistoryIndex: () => boolean;
|
|
506
|
-
|
|
508
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
509
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
507
510
|
setTitle: (title: string) => void;
|
|
508
511
|
returnToHistoryIndex: () => boolean;
|
|
509
512
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -573,7 +576,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
573
576
|
assignHistoryIndex: () => void;
|
|
574
577
|
inheritHistoryIndex: (index: number) => void;
|
|
575
578
|
ownsHistoryIndex: () => boolean;
|
|
576
|
-
|
|
579
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
580
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
577
581
|
setTitle: (title: string) => void;
|
|
578
582
|
returnToHistoryIndex: () => boolean;
|
|
579
583
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -1533,6 +1537,7 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
1533
1537
|
extendUrl(url: string): string;
|
|
1534
1538
|
match<Params>(template: string, params?: import('..').UrlParamsConstructors<Params> | undefined): import('..').UrlMatchResult<Params> | undefined;
|
|
1535
1539
|
matchCurrent<Params_1>(template: string, params?: import('..').UrlParamsConstructors<Params_1> | undefined): import('..').UrlMatchResult<Params_1> | undefined;
|
|
1540
|
+
overrideUrl(url: import('..').HistoryUrl, title?: string | undefined): void;
|
|
1536
1541
|
};
|
|
1537
1542
|
$navigate: <Params_2 extends Record<string, unknown>>(prop1: string | import('..').Route<Params_2, unknown>, prop2?: import('..').RouteNavigationOptions<Params_2> | undefined) => Promise<void>;
|
|
1538
1543
|
}, {}, {
|