@design.estate/dees-catalog 22.3.1 → 22.4.0

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.
@@ -65367,8 +65367,8 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
65367
65367
  __publicField(this, "historyIndex", 0);
65368
65368
  /** Numbers the history entries this shell writes, so an entry it pushes can name the one it was pushed from. */
65369
65369
  __publicField(this, "historyEntries", 0);
65370
- /** The location each history entry this shell wrote shows, by the entry's number: what a return finds before it (`returnsBack`). */
65371
- __publicField(this, "historyEntryLocations", /* @__PURE__ */ new Map());
65370
+ /** Each history entry this shell wrote, by its number: what a return finds before the current one (`stepsBackTo`). */
65371
+ __publicField(this, "historyEntryRecords", /* @__PURE__ */ new Map());
65372
65372
  /** The traversal back a refused browser change started, to `location`; the next change of any address ends it. */
65373
65373
  __publicField(this, "restoringHistory");
65374
65374
  /** A storage operation failed: the host hears it once, and the shell goes on without it. */
@@ -66637,15 +66637,32 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66637
66637
  * `options.history` decides whether that leaves a step behind: `push` (the
66638
66638
  * default) adds a history entry, `replace` rewrites the current one, which is
66639
66639
  * what a screen correcting its own route needs, and `return` goes back to the
66640
- * screen a step was taken from, where the entry before the current one shows
66641
- * it, and replaces the current entry elsewhere.
66640
+ * screen a flow was started from, across the steps it took on its own screen,
66641
+ * and replaces the current entry where no entry before shows it. With
66642
+ * `options.origin`, a return ends the flow on another screen, such as the one
66643
+ * it made: it goes back to the origin and pushes the screen after it.
66642
66644
  */
66643
66645
  navigateToView(viewId, params = {}, query2 = {}, options) {
66644
66646
  const mode = options?.history === "replace" || options?.history === "return" ? options.history : "push";
66645
- return this.queueNavigation(viewId, { ...params }, { ...query2 }, mode, mode === "replace" ? "system" : "reader");
66647
+ const origin = mode === "return" && options?.origin ? this.locationOf(options.origin) ?? null : void 0;
66648
+ return this.queueNavigation(
66649
+ viewId,
66650
+ { ...params },
66651
+ { ...query2 },
66652
+ mode,
66653
+ mode === "replace" ? "system" : "reader",
66654
+ void 0,
66655
+ void 0,
66656
+ origin
66657
+ );
66658
+ }
66659
+ /** The location of a screen named by a view and its parameters; none for a route that names no screen. */
66660
+ locationOf(routeArg) {
66661
+ const address = this.addressOf({ viewId: routeArg.viewId, params: { ...routeArg.params }, query: { ...routeArg.query } });
66662
+ return address === void 0 ? void 0 : this.addressing.locationOf(address);
66646
66663
  }
66647
- queueNavigation(viewId, params, query2, mode, intent, index, traversalLocation) {
66648
- return this.enqueue((generation, request) => this.performNavigation(viewId, params, query2, mode, intent, generation, request, index, traversalLocation));
66664
+ queueNavigation(viewId, params, query2, mode, intent, index, traversalLocation, origin) {
66665
+ return this.enqueue((generation, request) => this.performNavigation(viewId, params, query2, mode, intent, generation, request, index, traversalLocation, origin));
66649
66666
  }
66650
66667
  /**
66651
66668
  * Runs a navigation after every one queued before it. Each is numbered as it
@@ -66668,7 +66685,7 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66668
66685
  this.navigationQueue = result.catch(() => false);
66669
66686
  return result;
66670
66687
  }
66671
- async performNavigation(viewId, params, query2, mode, intent, generation, request, index, traversalLocation) {
66688
+ async performNavigation(viewId, params, query2, mode, intent, generation, request, index, traversalLocation, origin) {
66672
66689
  const stale = /* @__PURE__ */ __name(() => !this.isConnected || generation !== this.routingGeneration, "stale");
66673
66690
  const superseded = /* @__PURE__ */ __name(() => stale() || request !== this.latestNavigationRequest, "superseded");
66674
66691
  if (stale()) return false;
@@ -66725,11 +66742,16 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66725
66742
  void this.takeReaderTo(element);
66726
66743
  void this.announceView(view.name);
66727
66744
  }
66745
+ const stepsBack = mode === "return" && origin !== null ? this.stepsBackTo(origin ?? location) : 0;
66728
66746
  if (mode === "push") {
66729
66747
  this.historyIndex++;
66730
66748
  window.history.pushState(this.routeHistoryState(location, true), "", location);
66731
- } else if (mode === "return" && this.returnsBack(location)) {
66732
- await this.goBackTo(location);
66749
+ } else if (stepsBack > 0) {
66750
+ await this.goBackTo(origin ?? location, stepsBack);
66751
+ if (origin !== void 0 && origin !== location && !stale() && this.addressing.currentLocation() === origin) {
66752
+ this.historyIndex++;
66753
+ window.history.pushState(this.routeHistoryState(location, true), "", location);
66754
+ }
66733
66755
  } else {
66734
66756
  if (index !== void 0) this.historyIndex = index;
66735
66757
  if (mode === "replace" || mode === "return" || this.addressing.currentLocation() === traversalLocation) {
@@ -66740,7 +66762,7 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66740
66762
  } catch (error) {
66741
66763
  if (superseded()) return false;
66742
66764
  this.viewLifecycle$.next({ type: "loadError", viewId, error });
66743
- this.failedNavigation = { view, params, query: query2, mode, location };
66765
+ this.failedNavigation = { view, params, query: query2, mode, location, origin };
66744
66766
  this.markViewInMainMenu(viewId);
66745
66767
  return false;
66746
66768
  }
@@ -66782,7 +66804,8 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66782
66804
  const failed = this.failedNavigation;
66783
66805
  if (!failed) return;
66784
66806
  const mode = failed.mode === "replace" || this.addressing.currentLocation() === failed.location ? "replace" : failed.mode === "return" ? "return" : "push";
66785
- void this.queueNavigation(failed.view.id, failed.params, failed.query, mode, "reader");
66807
+ const origin = mode === "return" ? failed.origin : void 0;
66808
+ void this.queueNavigation(failed.view.id, failed.params, failed.query, mode, "reader", void 0, void 0, origin);
66786
66809
  }
66787
66810
  /**
66788
66811
  * A guard that returns a string asks a question, and the shell asks it in a
@@ -66809,15 +66832,17 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66809
66832
  * The state of a history entry the shell writes, showing a location: where the
66810
66833
  * entry stands (`historyIndex`) and a number of its own. An entry pushed also
66811
66834
  * names the entry it was pushed from, the one right before it; one rewritten
66812
- * keeps its number and the entry before it. The location an entry shows is
66813
- * kept by its number, so a return can tell what the entry before shows
66814
- * (`returnsBack`).
66835
+ * keeps its number and the entry before it. The location an entry shows, the
66836
+ * view on show there and the entry before it are kept by its number, so a
66837
+ * return can tell what the entries before show (`stepsBackTo`).
66815
66838
  */
66816
66839
  routeHistoryState(locationArg, pushedArg = false) {
66817
66840
  const current = this.historyMarker();
66818
66841
  const entry = pushedArg || !current ? ++this.historyEntries : current.entry;
66819
66842
  const previous = pushedArg ? current?.entry : current?.previous;
66820
- if (locationArg !== void 0) this.historyEntryLocations.set(entry, locationArg);
66843
+ if (locationArg !== void 0) {
66844
+ this.historyEntryRecords.set(entry, { location: locationArg, viewId: this.currentRoute?.viewId, previous });
66845
+ }
66821
66846
  const marker = { owner: this.historyOwner, index: this.historyIndex, entry, previous };
66822
66847
  return { ...window.history.state, deesAppui: marker };
66823
66848
  }
@@ -66841,29 +66866,42 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
66841
66866
  return current.location !== positionArg.location || current.index !== positionArg.index;
66842
66867
  }
66843
66868
  /**
66844
- * Whether a return to a location goes back: the browser stands where this
66845
- * shell is, on an entry it pushed, and the entry that one was pushed from —
66846
- * the one right before it — still shows the location. An entry the shell did
66847
- * not push from one of its own, such as the first one after a reload or a deep
66848
- * link into a flow, has no entry before it the shell knows, so a return from it
66849
- * replaces. So does one whose address shows the location already: going back
66850
- * from it would change no address, and no change would say it landed.
66869
+ * How many entries a return to a location goes back: the browser stands where
66870
+ * this shell is, on an entry it pushed, and walks back along the entries each
66871
+ * one was pushed from — the one right before it — to the nearest that shows
66872
+ * the location. The entries it passes are the steps of a flow on the current
66873
+ * entry's own screen; an entry of another screen in between was a stop of the
66874
+ * reader's own, so the walk ends there and the return replaces, as it does
66875
+ * from an entry the shell did not push from one of its own, such as the first
66876
+ * one after a reload or a deep link into a flow. So does a return from an
66877
+ * entry whose address shows the location already: going back from it would
66878
+ * change no address, and no change would say it landed. None is `0`.
66851
66879
  */
66852
- returnsBack(locationArg) {
66880
+ stepsBackTo(locationArg) {
66853
66881
  const marker = this.historyMarker();
66854
- return marker?.index === this.historyIndex && marker.previous !== void 0 && this.historyEntryLocations.get(marker.previous) === locationArg && this.addressing.currentLocation() !== locationArg;
66882
+ if (marker?.index !== this.historyIndex || this.addressing.currentLocation() === locationArg) return 0;
66883
+ const flowView = this.historyEntryRecords.get(marker.entry)?.viewId;
66884
+ let previous = marker.previous;
66885
+ for (let steps = 1; previous !== void 0; steps++) {
66886
+ const record = this.historyEntryRecords.get(previous);
66887
+ if (!record) return 0;
66888
+ if (record.location === locationArg) return steps;
66889
+ if (record.viewId !== flowView) return 0;
66890
+ previous = record.previous;
66891
+ }
66892
+ return 0;
66855
66893
  }
66856
66894
  /**
66857
- * Goes back one entry, to the location of the screen already on show, and
66858
- * waits until the browser stands there, so no request writes history from
66859
- * the entry it leaves. The change the browser brings finds that location
66860
- * and is not taken as a move of the reader's (`restoringHistory`).
66895
+ * Goes back a number of entries, to the location they show, and waits until
66896
+ * the browser stands there, so no request writes history from the entry it
66897
+ * leaves. The change the browser brings finds that location and is not taken
66898
+ * as a move of the reader's (`restoringHistory`).
66861
66899
  */
66862
- goBackTo(locationArg) {
66863
- this.historyIndex--;
66900
+ goBackTo(locationArg, stepsArg) {
66901
+ this.historyIndex -= stepsArg;
66864
66902
  return new Promise((resolve) => {
66865
66903
  this.restoringHistory = { location: locationArg, resolve };
66866
- window.history.back();
66904
+ window.history.go(-stepsArg);
66867
66905
  });
66868
66906
  }
66869
66907
  /**
@@ -67034,7 +67072,7 @@ var _DeesAppui = class _DeesAppui extends (_a86 = DeesElement, _appbarMenuItems_
67034
67072
  this.failedNavigation = void 0;
67035
67073
  this.historyOwner = `${Date.now()}-${Math.random()}`;
67036
67074
  this.historyIndex = 0;
67037
- this.historyEntryLocations.clear();
67075
+ this.historyEntryRecords.clear();
67038
67076
  }
67039
67077
  /** Follow the address: mark the entry the shell stands on, listen for its changes, show the first screen. */
67040
67078
  startRouting() {
@@ -127751,7 +127789,7 @@ var bright = {
127751
127789
  // ts_web/00_commitinfo_data.ts
127752
127790
  var commitinfo = {
127753
127791
  name: "@design.estate/dees-catalog",
127754
- version: "22.3.1",
127792
+ version: "22.4.0",
127755
127793
  description: "A comprehensive library that provides dynamic web components for building sophisticated and modern web applications using JavaScript and TypeScript."
127756
127794
  };
127757
127795
  export {