@jsenv/navi 0.29.82 → 0.29.83

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.
@@ -22656,6 +22656,24 @@ const scrollTo = ({ x, y }) => {
22656
22656
  const [publishBeforeRouting, observeBeforeRouting] = createPubSub();
22657
22657
  const [publishAfterRouting, observeAfterRouting] = createPubSub();
22658
22658
 
22659
+ /*
22660
+ * A press aims at a place; it does not always go one step deeper. A row of tabs
22661
+ * is a lateral move — the neighbour is one finger away — so the whole row should
22662
+ * weigh one history entry: the arrow at the top and the phone's back button then
22663
+ * leave by where the reader came in, and the swipe (which replaces already, see
22664
+ * route_travel.jsx) and the press say the same thing.
22665
+ *
22666
+ * `<Link replace>` is that, and it travels as an attribute because the click
22667
+ * handler sees the anchor, not the component that rendered it — the same mouth
22668
+ * as what a link asks of a route transition.
22669
+ */
22670
+
22671
+ const LINK_REPLACE_ATTRIBUTE = "data-navi-replace";
22672
+
22673
+ const linkAsksForReplace = (linkElement) => {
22674
+ return linkElement.hasAttribute(LINK_REPLACE_ATTRIBUTE);
22675
+ };
22676
+
22659
22677
  const setupBrowserIntegrationViaHistory = ({
22660
22678
  applyActions,
22661
22679
  applyRouting,
@@ -22936,7 +22954,9 @@ const setupBrowserIntegrationViaHistory = ({
22936
22954
  e.preventDefault();
22937
22955
  handleRoutingTask(href, {
22938
22956
  reason: `"click" on a[href="${href}"]`,
22939
- navigationType: "push",
22957
+ // A link that takes the place of the current entry instead of stacking
22958
+ // on it says so on itself (see link_replace.js).
22959
+ navigationType: linkAsksForReplace(linkElement) ? "replace" : "push",
22940
22960
  // Who started it. Announced with the navigation because a press
22941
22961
  // carries things the url does not: what a link asks of a route
22942
22962
  // transition is the first of them (see route_transition.jsx). Read by
@@ -44333,6 +44353,12 @@ Object.assign(PSEUDO_CLASSES, {
44333
44353
  * the pair's movement and only turns it round, which is what the rare way
44334
44354
  * round a pair usually needs. Said nowhere else, the relations answer as
44335
44355
  * they always do.
44356
+ * @param {boolean} [props.replace] - Go to the destination by TAKING THE PLACE
44357
+ * of the current history entry instead of stacking onto it: the link stays a
44358
+ * link (an address, a middle click, the keyboard, `aria-current`), only the
44359
+ * way there changes. What a row of tabs wants — the neighbour is a lateral
44360
+ * move, not a step deeper, so the whole row weighs one entry and the back
44361
+ * button leaves by where the reader came in.
44336
44362
  * @param {boolean} [props.preventDefault] - Call `event.preventDefault()` on
44337
44363
  * click (navigation suppressed; `onClick` still runs).
44338
44364
  * @param {(event: MouseEvent) => void} [props.onClick]
@@ -44397,6 +44423,7 @@ const LinkPlain = props => {
44397
44423
  revealOnInteraction = false,
44398
44424
  hrefFallback = !anchor,
44399
44425
  routeTransition,
44426
+ replace,
44400
44427
  children
44401
44428
  } = props;
44402
44429
  if (anchor && !props.id) {
@@ -44510,6 +44537,13 @@ const LinkPlain = props => {
44510
44537
  // a name; anything more travels as JSON, which is also how a plain <a>
44511
44538
  // writes it by hand.
44512
44539
  const routeTransitionRequest = routeTransition === undefined || routeTransition === null ? undefined : typeof routeTransition === "string" ? routeTransition : JSON.stringify(routeTransition);
44540
+
44541
+ // Which way this link goes to the place it aims at, worn as an attribute so
44542
+ // that whoever answers the press reads it off the anchor (see
44543
+ // link_replace.js, which owns the name and does the reading).
44544
+ const replaceRequest = replace ? {
44545
+ [LINK_REPLACE_ATTRIBUTE]: ""
44546
+ } : null;
44513
44547
  const innerChildren = children || (hrefFallback ? href : children);
44514
44548
  const startIconEl = startIcon;
44515
44549
  const endIconEl = innerEndIcon;
@@ -44561,7 +44595,9 @@ const LinkPlain = props => {
44561
44595
  endIcon: undefined,
44562
44596
  hrefFallback: undefined,
44563
44597
  routeTransition: undefined,
44598
+ replace: undefined,
44564
44599
  "data-navi-route-transition-request": routeTransitionRequest,
44600
+ ...replaceRequest,
44565
44601
  onClick: e => {
44566
44602
  onClick?.(e);
44567
44603
  if (slide) {