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