@jsenv/navi 0.29.50 → 0.29.51

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.
@@ -49186,6 +49186,21 @@ const readArea = slideElement => slideElement.getAttribute("data-slide-area") ||
49186
49186
  * a component of your own wrapping one. Nothing here assumes the children ARE
49187
49187
  * the slides, so nothing breaks when they are not.
49188
49188
  *
49189
+ * Only slides go in it, so everything drawn AROUND the travel is written around
49190
+ * the box and reaches it by id: a chevron pinned to the edge of a full-screen
49191
+ * viewer, a "3 / 8" counter under it, a tab bar. Two things are said to such an
49192
+ * element, and both are needed for it to feel part of the same thing:
49193
+ * `commandFor={id}` on a button, which is how it asks for a travel
49194
+ * (--navi-left/--navi-right/--navi-first/…), and
49195
+ * `data-slide-container-follows={id}` on whatever holds them, which makes it a
49196
+ * follower: the travel's progress is painted onto it to draw with, and the
49197
+ * arrows walk the slides wherever the focus is inside it — otherwise they stop
49198
+ * working the moment one Tabs onto the chevron that walks them. Say it on the
49199
+ * outermost element of the surface — the <Dialog> itself rather than a box
49200
+ * inside it — since that is what holds the keyboard when nothing in it does.
49201
+ * <Nav slideContainer={id}> is a tab bar built out of exactly that. See the
49202
+ * full-screen section of the demo.
49203
+ *
49189
49204
  * @param {object} props
49190
49205
  * @param {"row"|"column"|string[]} [props.layout="row"] - where the slides are.
49191
49206
  * A word for a line — "row" to the right, "column" downwards, both in DOM
@@ -50699,6 +50714,38 @@ const SlideContainer = ({
50699
50714
  handler: e => travelled(goToEnd(true, e))
50700
50715
  }
50701
50716
  });
50717
+ // …and they are the same shortcuts wherever they are pressed in what follows
50718
+ // this box: a shortcut only ever reaches what has the focus, and a way out
50719
+ // drawn BESIDE the container — a chevron in the column next to it, a counter
50720
+ // one can Tab to — is not inside it. So the arrows that walk the slides stop
50721
+ // walking the moment one Tabs onto the chevron that walks them. A follower
50722
+ // already says which box it is about (data-slide-container-follows), which is
50723
+ // the same thing said for the same reason.
50724
+ // Read on every render: a follower appearing is not a render of this box, and
50725
+ // the list is refreshed by the layout effect above, which runs first.
50726
+ useLayoutEffect(() => {
50727
+ const followerElements = followerElementsRef.current;
50728
+ if (followerElements.length === 0) {
50729
+ return undefined;
50730
+ }
50731
+ const onFollowerKeyDown = keyDownEvent => {
50732
+ // Already answered: a follower AROUND this box — the frame of a
50733
+ // full-screen surface, holding the slides and the ways out — hears the
50734
+ // same press bubbling out of it.
50735
+ if (containerRef.current?.contains(keyDownEvent.target)) {
50736
+ return;
50737
+ }
50738
+ onKeyDownShortcuts(keyDownEvent);
50739
+ };
50740
+ for (const followerElement of followerElements) {
50741
+ followerElement.addEventListener("keydown", onFollowerKeyDown);
50742
+ }
50743
+ return () => {
50744
+ for (const followerElement of followerElements) {
50745
+ followerElement.removeEventListener("keydown", onFollowerKeyDown);
50746
+ }
50747
+ };
50748
+ });
50702
50749
  return (
50703
50750
  // Box rather than a plain div: it is how every navi component takes the
50704
50751
  // onnavi_* handlers below — they are navi's own event names, and Box is