@simonbackx/vue-app-navigation 2.5.0 → 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 +13 -7
- package/dist/src/ComponentWithProperties.d.ts +3 -2
- package/dist/src/HistoryManager.d.ts +7 -2
- package/dist/src/ModalMixin.d.ts +8 -8
- package/dist/src/ModalStackComponent.vue.d.ts +4 -4
- package/dist/src/StackComponent.vue.d.ts +2 -2
- package/dist/src/utils/navigationHooks.d.ts +3 -2
- package/dist/test/EditWebshopMixin.d.ts +9 -9
- 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
|
}
|
|
@@ -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,8 +47,8 @@ export declare class ComponentWithProperties {
|
|
|
46
47
|
assignHistoryIndex(): void;
|
|
47
48
|
inheritHistoryIndex(index: number): void;
|
|
48
49
|
ownsHistoryIndex(): boolean;
|
|
49
|
-
overrideUrl(url:
|
|
50
|
-
setUrl(url:
|
|
50
|
+
overrideUrl(url: HistoryUrl, title?: string): void;
|
|
51
|
+
setUrl(url: HistoryUrl, title?: string): void;
|
|
51
52
|
setTitle(title: string): void;
|
|
52
53
|
/**
|
|
53
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,8 +66,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
66
66
|
assignHistoryIndex: () => void;
|
|
67
67
|
inheritHistoryIndex: (index: number) => void;
|
|
68
68
|
ownsHistoryIndex: () => boolean;
|
|
69
|
-
overrideUrl: (url:
|
|
70
|
-
setUrl: (url:
|
|
69
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
70
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
71
71
|
setTitle: (title: string) => void;
|
|
72
72
|
returnToHistoryIndex: () => boolean;
|
|
73
73
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -137,8 +137,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
137
137
|
assignHistoryIndex: () => void;
|
|
138
138
|
inheritHistoryIndex: (index: number) => void;
|
|
139
139
|
ownsHistoryIndex: () => boolean;
|
|
140
|
-
overrideUrl: (url:
|
|
141
|
-
setUrl: (url:
|
|
140
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
141
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
142
142
|
setTitle: (title: string) => void;
|
|
143
143
|
returnToHistoryIndex: () => boolean;
|
|
144
144
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -442,8 +442,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
442
442
|
assignHistoryIndex: () => void;
|
|
443
443
|
inheritHistoryIndex: (index: number) => void;
|
|
444
444
|
ownsHistoryIndex: () => boolean;
|
|
445
|
-
overrideUrl: (url:
|
|
446
|
-
setUrl: (url:
|
|
445
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
446
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
447
447
|
setTitle: (title: string) => void;
|
|
448
448
|
returnToHistoryIndex: () => boolean;
|
|
449
449
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -513,8 +513,8 @@ export declare const ModalMixin: import('vue').DefineComponent<{}, {}, {}, {}, {
|
|
|
513
513
|
assignHistoryIndex: () => void;
|
|
514
514
|
inheritHistoryIndex: (index: number) => void;
|
|
515
515
|
ownsHistoryIndex: () => boolean;
|
|
516
|
-
overrideUrl: (url:
|
|
517
|
-
setUrl: (url:
|
|
516
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
517
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
518
518
|
setTitle: (title: string) => void;
|
|
519
519
|
returnToHistoryIndex: () => boolean;
|
|
520
520
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -65,8 +65,8 @@ declare const ModalStackComponent: import('vue').DefineComponent<{
|
|
|
65
65
|
assignHistoryIndex: () => void;
|
|
66
66
|
inheritHistoryIndex: (index: number) => void;
|
|
67
67
|
ownsHistoryIndex: () => boolean;
|
|
68
|
-
overrideUrl: (url:
|
|
69
|
-
setUrl: (url:
|
|
68
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
69
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
70
70
|
setTitle: (title: string) => void;
|
|
71
71
|
returnToHistoryIndex: () => boolean;
|
|
72
72
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -136,8 +136,8 @@ declare const ModalStackComponent: import('vue').DefineComponent<{
|
|
|
136
136
|
assignHistoryIndex: () => void;
|
|
137
137
|
inheritHistoryIndex: (index: number) => void;
|
|
138
138
|
ownsHistoryIndex: () => boolean;
|
|
139
|
-
overrideUrl: (url:
|
|
140
|
-
setUrl: (url:
|
|
139
|
+
overrideUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
140
|
+
setUrl: (url: import('./HistoryManager').HistoryUrl, title?: string | undefined) => void;
|
|
141
141
|
setTitle: (title: string) => void;
|
|
142
142
|
returnToHistoryIndex: () => boolean;
|
|
143
143
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -45,8 +45,8 @@ declare const StackComponent: import('vue').DefineComponent<{}, {}, {
|
|
|
45
45
|
assignHistoryIndex: () => void;
|
|
46
46
|
inheritHistoryIndex: (index: number) => void;
|
|
47
47
|
ownsHistoryIndex: () => boolean;
|
|
48
|
-
overrideUrl: (url:
|
|
49
|
-
setUrl: (url:
|
|
48
|
+
overrideUrl: (url: import('./HistoryManager.ts').HistoryUrl, title?: string | undefined) => void;
|
|
49
|
+
setUrl: (url: import('./HistoryManager.ts').HistoryUrl, title?: string | undefined) => void;
|
|
50
50
|
setTitle: (title: string) => void;
|
|
51
51
|
returnToHistoryIndex: () => boolean;
|
|
52
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,7 +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;
|
|
89
|
-
export declare function setUrl(url:
|
|
90
|
+
export declare function setUrl(url: HistoryUrl, title?: string): void;
|
|
90
91
|
export declare function useUrl(): {
|
|
91
92
|
getUrl(): string;
|
|
92
93
|
/**
|
|
@@ -96,5 +97,5 @@ export declare function useUrl(): {
|
|
|
96
97
|
extendUrl(url: string): string;
|
|
97
98
|
match<Params>(template: string, params?: UrlParamsConstructors<Params>): UrlMatchResult<Params> | undefined;
|
|
98
99
|
matchCurrent<Params_1>(template: string, params?: UrlParamsConstructors<Params_1> | undefined): UrlMatchResult<Params_1> | undefined;
|
|
99
|
-
overrideUrl(url:
|
|
100
|
+
overrideUrl(url: HistoryUrl, title?: string): void;
|
|
100
101
|
};
|
|
@@ -129,8 +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
|
-
overrideUrl: (url:
|
|
133
|
-
setUrl: (url:
|
|
132
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
133
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
134
134
|
setTitle: (title: string) => void;
|
|
135
135
|
returnToHistoryIndex: () => boolean;
|
|
136
136
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -200,8 +200,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
200
200
|
assignHistoryIndex: () => void;
|
|
201
201
|
inheritHistoryIndex: (index: number) => void;
|
|
202
202
|
ownsHistoryIndex: () => boolean;
|
|
203
|
-
overrideUrl: (url:
|
|
204
|
-
setUrl: (url:
|
|
203
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
204
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
205
205
|
setTitle: (title: string) => void;
|
|
206
206
|
returnToHistoryIndex: () => boolean;
|
|
207
207
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -505,8 +505,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
505
505
|
assignHistoryIndex: () => void;
|
|
506
506
|
inheritHistoryIndex: (index: number) => void;
|
|
507
507
|
ownsHistoryIndex: () => boolean;
|
|
508
|
-
overrideUrl: (url:
|
|
509
|
-
setUrl: (url:
|
|
508
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
509
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
510
510
|
setTitle: (title: string) => void;
|
|
511
511
|
returnToHistoryIndex: () => boolean;
|
|
512
512
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -576,8 +576,8 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
576
576
|
assignHistoryIndex: () => void;
|
|
577
577
|
inheritHistoryIndex: (index: number) => void;
|
|
578
578
|
ownsHistoryIndex: () => boolean;
|
|
579
|
-
overrideUrl: (url:
|
|
580
|
-
setUrl: (url:
|
|
579
|
+
overrideUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
580
|
+
setUrl: (url: import('..').HistoryUrl, title?: string | undefined) => void;
|
|
581
581
|
setTitle: (title: string) => void;
|
|
582
582
|
returnToHistoryIndex: () => boolean;
|
|
583
583
|
componentInstance: () => import('vue').ComponentPublicInstance | null;
|
|
@@ -1537,7 +1537,7 @@ declare const EditWebshopMixin_base: new (...args: any) => import('../src/class-
|
|
|
1537
1537
|
extendUrl(url: string): string;
|
|
1538
1538
|
match<Params>(template: string, params?: import('..').UrlParamsConstructors<Params> | undefined): import('..').UrlMatchResult<Params> | undefined;
|
|
1539
1539
|
matchCurrent<Params_1>(template: string, params?: import('..').UrlParamsConstructors<Params_1> | undefined): import('..').UrlMatchResult<Params_1> | undefined;
|
|
1540
|
-
overrideUrl(url:
|
|
1540
|
+
overrideUrl(url: import('..').HistoryUrl, title?: string | undefined): void;
|
|
1541
1541
|
};
|
|
1542
1542
|
$navigate: <Params_2 extends Record<string, unknown>>(prop1: string | import('..').Route<Params_2, unknown>, prop2?: import('..').RouteNavigationOptions<Params_2> | undefined) => Promise<void>;
|
|
1543
1543
|
}, {}, {
|