@simonbackx/vue-app-navigation 2.17.0 → 2.17.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 +71 -33
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -391,6 +391,9 @@ class HistoryManagerStatic {
|
|
|
391
391
|
if (!this.active) {
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
|
+
if (this.debug) {
|
|
395
|
+
console.log("Set title: " + title + ", for index " + (index ?? this.counter) + " with current counter: " + this.counter);
|
|
396
|
+
}
|
|
394
397
|
if (index === void 0 || index === this.counter) {
|
|
395
398
|
const state = this.states[this.states.length - 1];
|
|
396
399
|
window.document.title = this.formatTitle(title);
|
|
@@ -534,11 +537,11 @@ class HistoryManagerStatic {
|
|
|
534
537
|
const newCounter = (_a = event.state) == null ? void 0 : _a.counter;
|
|
535
538
|
if (newCounter !== void 0) {
|
|
536
539
|
if (newCounter > this.counter) {
|
|
537
|
-
const amount = newCounter - this.counter;
|
|
538
|
-
this.go(-amount);
|
|
539
540
|
if (this.debug) {
|
|
540
|
-
console.log("
|
|
541
|
+
console.log("Reloading page because going forward is not supported");
|
|
541
542
|
}
|
|
543
|
+
window.location.reload();
|
|
544
|
+
return;
|
|
542
545
|
} else {
|
|
543
546
|
const animate = this.counter - newCounter == 1 && this.animateHistoryPop;
|
|
544
547
|
this.counter = newCounter;
|
|
@@ -823,9 +826,6 @@ const _ComponentWithProperties = class _ComponentWithProperties {
|
|
|
823
826
|
console.warn("Returning to a component that has no history index assigned. Has this component been pushed to a navigation controller properly before returning to it?", this.component.name);
|
|
824
827
|
return false;
|
|
825
828
|
}
|
|
826
|
-
_ComponentWithProperties.historyIndexOwners.set(this.historyIndex, this);
|
|
827
|
-
if (_ComponentWithProperties.debug)
|
|
828
|
-
console.log("New owner of history index ", this.historyIndex, this.component.name);
|
|
829
829
|
HistoryManager.returnToHistoryIndex(this.historyIndex);
|
|
830
830
|
return true;
|
|
831
831
|
}
|
|
@@ -888,6 +888,7 @@ const _ComponentWithProperties = class _ComponentWithProperties {
|
|
|
888
888
|
} else {
|
|
889
889
|
console.error("No unmount function for component " + this.vnode);
|
|
890
890
|
}
|
|
891
|
+
this.deleteHistoryIndex();
|
|
891
892
|
this.vnode = null;
|
|
892
893
|
}
|
|
893
894
|
}
|
|
@@ -1454,47 +1455,84 @@ const _sfc_main$4 = defineComponent({
|
|
|
1454
1455
|
if (animated) {
|
|
1455
1456
|
this.freezeSize();
|
|
1456
1457
|
}
|
|
1458
|
+
let popped = [];
|
|
1459
|
+
const adjustHistory = (options == null ? void 0 : options.adjustHistory) ?? true;
|
|
1457
1460
|
if (replace > 0) {
|
|
1458
|
-
|
|
1461
|
+
popped = this.components.splice(this.components.length - replace, replace, ...components);
|
|
1459
1462
|
if (!destroy) {
|
|
1460
1463
|
for (const comp of popped) {
|
|
1461
1464
|
comp.keepAlive = true;
|
|
1462
1465
|
}
|
|
1463
1466
|
}
|
|
1464
|
-
if (this.components.length
|
|
1465
|
-
|
|
1467
|
+
if (this.components.length <= components.length) {
|
|
1468
|
+
const lastComponent = popped[0];
|
|
1469
|
+
if (HistoryManager.active) {
|
|
1470
|
+
if (lastComponent && lastComponent.hasHistoryIndex()) {
|
|
1471
|
+
HistoryManager.returnToHistoryIndex(lastComponent.historyIndex - 1);
|
|
1472
|
+
} else {
|
|
1473
|
+
console.log("Last removed component has no history index", popped);
|
|
1474
|
+
HistoryManager.invalidateHistory();
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
} else {
|
|
1478
|
+
const lastComponent = this.components[this.components.length - components.length - 1];
|
|
1479
|
+
if (lastComponent && lastComponent.hasHistoryIndex()) {
|
|
1480
|
+
lastComponent.returnToHistoryIndex();
|
|
1481
|
+
} else {
|
|
1482
|
+
console.log("Last visible component has no history index", lastComponent);
|
|
1483
|
+
HistoryManager.invalidateHistory();
|
|
1484
|
+
}
|
|
1466
1485
|
}
|
|
1467
1486
|
} else {
|
|
1468
1487
|
this.components.push(...components);
|
|
1469
1488
|
}
|
|
1470
1489
|
if (this.mainComponent) {
|
|
1471
|
-
this.mainComponent.keepAlive = !replace;
|
|
1490
|
+
this.mainComponent.keepAlive = !replace || !destroy;
|
|
1472
1491
|
}
|
|
1473
|
-
const adjustHistory = (options == null ? void 0 : options.adjustHistory) ?? true;
|
|
1474
1492
|
if (adjustHistory) {
|
|
1475
|
-
for (const component2 of components) {
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
if (!replace || this.components.length !== components.length) {
|
|
1491
|
-
HistoryManager.pushState(void 0, null, {
|
|
1493
|
+
for (const [index, component2] of components.entries()) {
|
|
1494
|
+
if (index === 0 && popped.length) {
|
|
1495
|
+
HistoryManager.pushState(void 0, async (canAnimate) => {
|
|
1496
|
+
if (!this.mainComponent) {
|
|
1497
|
+
console.error("Tried to pop NavigationController, but it was already unmounted");
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
await this.push({
|
|
1501
|
+
animated: animated && canAnimate,
|
|
1502
|
+
replace: 1,
|
|
1503
|
+
components: popped,
|
|
1504
|
+
reverse: !(options.reverse ?? false),
|
|
1505
|
+
adjustHistory: false
|
|
1506
|
+
});
|
|
1507
|
+
}, {
|
|
1492
1508
|
adjustHistory,
|
|
1493
|
-
invalid: options.invalidHistory ??
|
|
1509
|
+
invalid: options.invalidHistory ?? false
|
|
1510
|
+
});
|
|
1511
|
+
} else {
|
|
1512
|
+
HistoryManager.pushState(void 0, async (canAnimate) => {
|
|
1513
|
+
if (!this.mainComponent) {
|
|
1514
|
+
console.error("Tried to pop NavigationController, but it was already unmounted");
|
|
1515
|
+
return;
|
|
1516
|
+
}
|
|
1517
|
+
await this.pop({ animated: animated && canAnimate });
|
|
1518
|
+
}, {
|
|
1519
|
+
adjustHistory,
|
|
1520
|
+
invalid: options.invalidHistory ?? false
|
|
1494
1521
|
});
|
|
1495
1522
|
}
|
|
1496
1523
|
component2.assignHistoryIndex();
|
|
1497
1524
|
}
|
|
1525
|
+
} else {
|
|
1526
|
+
for (const [index, component2] of components.entries()) {
|
|
1527
|
+
HistoryManager.pushState(void 0, !!replace && index === 0 ? async (animated2) => {
|
|
1528
|
+
await this.pop({ animated: animated2, count: components.length });
|
|
1529
|
+
} : null, {
|
|
1530
|
+
adjustHistory: !!replace && index === 0,
|
|
1531
|
+
// for the first one we need to adjust the history because we returned earlier
|
|
1532
|
+
invalid: options.invalidHistory ?? false
|
|
1533
|
+
});
|
|
1534
|
+
component2.assignHistoryIndex();
|
|
1535
|
+
}
|
|
1498
1536
|
}
|
|
1499
1537
|
this.mainComponent = component;
|
|
1500
1538
|
this.$emit("didPush");
|
|
@@ -2857,10 +2895,10 @@ const _sfc_main = defineComponent({
|
|
|
2857
2895
|
this.getScrollElement().scrollTop = 0;
|
|
2858
2896
|
HistoryManager.pushState(void 0, null, {
|
|
2859
2897
|
adjustHistory: options.adjustHistory ?? true,
|
|
2860
|
-
invalid: options.invalidHistory
|
|
2898
|
+
invalid: !!options.invalidHistory || !!this.detail
|
|
2861
2899
|
});
|
|
2900
|
+
component.assignHistoryIndex();
|
|
2862
2901
|
this.detail = component;
|
|
2863
|
-
this.detail.assignHistoryIndex();
|
|
2864
2902
|
}
|
|
2865
2903
|
} finally {
|
|
2866
2904
|
this.isChangingComponents = false;
|
|
@@ -2887,13 +2925,13 @@ const _sfc_main = defineComponent({
|
|
|
2887
2925
|
console.error("Cannot collapse while already isChangingComponents");
|
|
2888
2926
|
return;
|
|
2889
2927
|
}
|
|
2928
|
+
console.log("Collapse SplitViewController");
|
|
2890
2929
|
this.isChangingComponents = true;
|
|
2891
2930
|
try {
|
|
2892
2931
|
this.detail.keepAlive = true;
|
|
2893
2932
|
const detail = this.detail;
|
|
2894
2933
|
this.detail = null;
|
|
2895
2934
|
await this.navigationController.push({ components: [detail], animated: false });
|
|
2896
|
-
HistoryManager.invalidateHistory();
|
|
2897
2935
|
} finally {
|
|
2898
2936
|
this.isChangingComponents = false;
|
|
2899
2937
|
}
|
|
@@ -2929,12 +2967,12 @@ const _sfc_main = defineComponent({
|
|
|
2929
2967
|
console.error("Cannot expand while already isChangingComponents");
|
|
2930
2968
|
return false;
|
|
2931
2969
|
}
|
|
2970
|
+
console.log("Expand SplitViewController");
|
|
2932
2971
|
if (!this.lastIsDetail) {
|
|
2933
2972
|
if (!this.defaultHandler) {
|
|
2934
2973
|
console.error("Cannot expand when there is no defaultHandler");
|
|
2935
2974
|
return;
|
|
2936
2975
|
}
|
|
2937
|
-
HistoryManager.invalidateHistory();
|
|
2938
2976
|
this.isChangingComponents = false;
|
|
2939
2977
|
try {
|
|
2940
2978
|
const succeeded = await this.defaultHandler();
|