@jsenv/navi 0.29.450 → 0.29.452

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.
@@ -32840,6 +32840,34 @@ const pushPopupThemeColor = ({
32840
32840
  };
32841
32841
  };
32842
32842
 
32843
+ /**
32844
+ * What a popup's wall paints, read off the `--backdrop-background` it is
32845
+ * painted from rather than off the wall: for the length of a route transition
32846
+ * played on an area the wall itself is turned transparent and stood in for
32847
+ * (transition_furniture.js), and a popup opening then would find nothing laid
32848
+ * over the edge. The variable holds a token list, resolved to a colour on an
32849
+ * element of its own, given what the wall inherits that a colour depends on:
32850
+ * color-scheme for light-dark() and the system colours, color for
32851
+ * currentcolor.
32852
+ *
32853
+ * @param {Element} element - The element declaring the variable: the dialog
32854
+ * for its ::backdrop, a popover's wall for itself.
32855
+ * @returns {string}
32856
+ */
32857
+ const readBackdropColor = (element) => {
32858
+ const elementStyle = getComputedStyle(element);
32859
+ const probe = document.createElement("div");
32860
+ probe.style.colorScheme = elementStyle.colorScheme;
32861
+ probe.style.color = elementStyle.color;
32862
+ probe.style.background = elementStyle.getPropertyValue(
32863
+ "--backdrop-background",
32864
+ );
32865
+ document.body.append(probe);
32866
+ const color = getComputedStyle(probe).backgroundColor;
32867
+ probe.remove();
32868
+ return color;
32869
+ };
32870
+
32843
32871
  let renderQueued = false;
32844
32872
  // Once per commit: a Head re-rendering leaves and arrives again in the same
32845
32873
  // commit, and the browser must not be handed the colour from in between.
@@ -34061,9 +34089,16 @@ const WALL_ATTRIBUTE = "data-navi-transition-wall";
34061
34089
  // property would replace it.
34062
34090
  const FURNITURE_ATTRIBUTE = "data-navi-transition-furniture";
34063
34091
  // What the wall paints, resolved on the matched element in both cases (the
34064
- // dialog for its ::backdrop, the popover's wall for itself): the same two
34065
- // properties, copied onto the stand-in.
34066
- const WALL_PROPERTIES = ["--backdrop-background", "--backdrop-filter"];
34092
+ // dialog for its ::backdrop, the popover's wall for itself), and what a colour
34093
+ // in it depends on: color-scheme for light-dark() and the system colours,
34094
+ // color for currentcolor. Copied onto the stand-in, which paints them in a
34095
+ // context of its own.
34096
+ const WALL_PROPERTIES = [
34097
+ "--backdrop-background",
34098
+ "--backdrop-filter",
34099
+ "color-scheme",
34100
+ "color",
34101
+ ];
34067
34102
 
34068
34103
  // The pictures the wall is painted into: the pages', and every bar's own.
34069
34104
  const FIXED_BAR_SELECTOR$1 = ".navi_fixed_bar";
@@ -42520,6 +42555,7 @@ const useUIStateController = (
42520
42555
  if (
42521
42556
  e.type === "facade_propagate_up" ||
42522
42557
  e.type === "cancel_rollback" ||
42558
+ e.type === "navi_reset_ui_state" ||
42523
42559
  e.type === "auto_fix"
42524
42560
  ) {
42525
42561
  // Exception: when the facade propagates a child state change up to the
@@ -42529,7 +42565,9 @@ const useUIStateController = (
42529
42565
  // the Form's uiAction fires on every value change.
42530
42566
  // A cancel takes the same road back: the Form was told what the
42531
42567
  // popup was picking, so it has to be told the picker went back to
42532
- // where it opened, or it sends a value the user said no to.
42568
+ // where it opened, or it sends a value the user said no to. A
42569
+ // reset is that road too, for a field put back after its own
42570
+ // action failed.
42533
42571
  // A correction is the same story once more: the Form sends what
42534
42572
  // its fields add up to, and a field that just put its own value
42535
42573
  // right has to be counted for the corrected one.
@@ -44595,6 +44633,13 @@ const INTERNAL_EVENT_SET = new Set([
44595
44633
  // notification below still happen, exactly as they did on the way in (see
44596
44634
  // picker_custom.jsx's onClose).
44597
44635
  "cancel_rollback",
44636
+ // A rollback navi asks for (see dispatchRequestResetUIState): the action
44637
+ // failed or was aborted, the edit was cancelled, a reset command aimed here.
44638
+ // Nobody acted on the control, so no command — a `<Picker type="confirm"
44639
+ // action command>` refused by the server would otherwise go where only its
44640
+ // success leads. Where the value moves back, uiAction and the parent
44641
+ // notification below still happen, as for cancel_rollback.
44642
+ "navi_reset_ui_state",
44598
44643
  // A constraint allowed to correct the value put it right as the value was
44599
44644
  // committed (see applyAutoFix). Nobody pressed anything, so no command and
44600
44645
  // no action of the control's own — but what it holds really did move, so
@@ -56321,24 +56366,32 @@ const ControlSwap = props => {
56321
56366
  }
56322
56367
  // Reading .value during render is what subscribes the row to it.
56323
56368
  const valueRequested = signal ? signal.value : value;
56324
- const [activeName, setActiveName] = useState(() => {
56369
+ // The side holding the floor, and the cap whose press gave it (null when
56370
+ // `value`/`signal` did): which cap was pressed decides where the focus goes.
56371
+ const [floor, setFloor] = useState(() => {
56325
56372
  const nameRequested = valueRequested === undefined ? defaultValue : valueRequested;
56326
- return nameRequested === undefined ? sides[0].name : nameRequested;
56373
+ return {
56374
+ name: nameRequested === undefined ? sides[0].name : nameRequested,
56375
+ pressedCapIndex: null
56376
+ };
56327
56377
  });
56328
- const activeIndexFound = sides.findIndex(side => side.name === activeName);
56378
+ const activeIndexFound = sides.findIndex(side => side.name === floor.name);
56329
56379
  const activeIndex = activeIndexFound === -1 ? 0 : activeIndexFound;
56330
56380
  const activeSide = sides[activeIndex];
56331
56381
  const capRefs = [useRef(), useRef()];
56332
56382
  const slotRefs = [useRef(), useRef()];
56333
56383
  const slotIdPrefix = useId();
56334
- const activeNameRef = useRef(activeName);
56384
+ const activeNameRef = useRef(floor.name);
56335
56385
  activeNameRef.current = activeSide.name;
56336
- const swapTo = (name, event) => {
56386
+ const swapTo = (name, event, pressedCapIndex = null) => {
56337
56387
  if (name === activeNameRef.current) {
56338
56388
  return;
56339
56389
  }
56340
56390
  activeNameRef.current = name;
56341
- setActiveName(name);
56391
+ setFloor({
56392
+ name,
56393
+ pressedCapIndex
56394
+ });
56342
56395
  if (signal) {
56343
56396
  signal.value = name;
56344
56397
  }
@@ -56371,14 +56424,14 @@ const ControlSwap = props => {
56371
56424
  isFirstActiveRunRef.current = false;
56372
56425
  return;
56373
56426
  }
56374
- focusWithTheFloor(slotRefs[activeIndex].current, activeSide, capRefs[activeIndex].current);
56427
+ focusWithTheFloor(slotRefs[activeIndex].current, activeSide, capRefs[activeIndex].current, floor.pressedCapIndex === null ? null : capRefs[floor.pressedCapIndex].current);
56375
56428
  }, [activeSide.name]);
56376
56429
 
56377
56430
  // Both caps do the same thing, and it is the reason they sit outside the
56378
56431
  // controls: whichever one the finger lands on, the floor goes to the other
56379
56432
  // side. The same pixel opens the search and closes it.
56380
- const swapOnPress = event => {
56381
- swapTo(sides[activeIndex === 0 ? 1 : 0].name, event);
56433
+ const swapOnPress = (event, pressedCapIndex) => {
56434
+ swapTo(sides[activeIndex === 0 ? 1 : 0].name, event, pressedCapIndex);
56382
56435
  };
56383
56436
  return jsxs(Box, {
56384
56437
  flex: "x",
@@ -56392,7 +56445,7 @@ const ControlSwap = props => {
56392
56445
  side: sides[0],
56393
56446
  slotId: `${slotIdPrefix}_0`,
56394
56447
  active: activeIndex === 0,
56395
- onPress: swapOnPress
56448
+ onPress: event => swapOnPress(event, 0)
56396
56449
  }), jsx("div", {
56397
56450
  className: "navi_control_swap_stage",
56398
56451
  children: jsx("div", {
@@ -56410,7 +56463,7 @@ const ControlSwap = props => {
56410
56463
  side: sides[1],
56411
56464
  slotId: `${slotIdPrefix}_1`,
56412
56465
  active: activeIndex === 1,
56413
- onPress: swapOnPress
56466
+ onPress: event => swapOnPress(event, 1)
56414
56467
  })]
56415
56468
  });
56416
56469
  };
@@ -56441,12 +56494,14 @@ const ControlSwap = props => {
56441
56494
  * the collapsed one — the side holding the floor spells out in full what a
56442
56495
  * dot could only hint at — so it is read straight off the state
56443
56496
  * (`badge={Boolean(groupId)}`), with no "and this side is hidden" to add.
56444
- * @param autoFocus - On by default: the focus goes into this control when it
56445
- * takes the floor, where navi's ladder puts it — an `autoFocus` inside the
56446
- * control first, its first focusable otherwise. `false` leaves it on the cap
56447
- * that was pressed, for a control one reads before writing in (and, on a
56448
- * phone, for a keyboard that must not rise). Never on mount, whatever the
56449
- * setting.
56497
+ * @param autoFocus - On by default: the focus goes into this control when its
56498
+ * own cap (or `value`/`signal`) gives it the floor, where navi's ladder puts
56499
+ * it — an `autoFocus` inside the control first, its first focusable
56500
+ * otherwise. `false` leaves it on the cap that was pressed, for a control one
56501
+ * reads before writing in (and, on a phone, for a keyboard that must not
56502
+ * rise). Whatever the setting, never on mount, and never when the floor comes
56503
+ * back because the other side was put away by its own cap: that press closed
56504
+ * something, it did not ask for this control.
56450
56505
  *
56451
56506
  * Anything else — `data-testid`, `variant`, `backgroundColor`, `color`, an
56452
56507
  * `aria-describedby` — goes to the cap, which is a `<Button>`. It is the one
@@ -56521,9 +56576,13 @@ const readSides = children => {
56521
56576
  return sides;
56522
56577
  };
56523
56578
 
56524
- // The floor moved: the press that gave it landed on a cap, and what one wants
56525
- // next is the control that just arrived — typing into the search field one just
56526
- // opened, not pressing its icon again.
56579
+ // The floor moved. A press on the arriving side's own cap — the collapsed one —
56580
+ // asks for that control: what one wants next is typing into the search field
56581
+ // one just opened, not pressing its icon again. A press on the other cap puts
56582
+ // the side holding the floor away, and the arriving one only comes back because
56583
+ // the row has room for one control: the focus stays on the cap pressed, and on
56584
+ // a phone no keyboard rises over the list one went back to. A swap with no
56585
+ // press behind it (`value`/`signal` moved) is taken as asking for the arrival.
56527
56586
  //
56528
56587
  // WHERE inside is navi's own ladder (findFocusTarget): an `autoFocus` in the
56529
56588
  // control's own content first, the first focusable otherwise, a last resort
@@ -56538,8 +56597,9 @@ const readSides = children => {
56538
56597
  // open". A field marked that way so its sheet opens quietly would otherwise
56539
56598
  // leave the focus on the magnifier that was pressed to reach it.
56540
56599
  // A side one reads before writing in says `autoFocus={false}`.
56541
- const focusWithTheFloor = (arrivingSlot, arrivingSide, arrivingCap) => {
56542
- if (arrivingSide.autoFocus !== false) {
56600
+ const focusWithTheFloor = (arrivingSlot, arrivingSide, arrivingCap, pressedCap) => {
56601
+ const arrivalAskedFor = !pressedCap || pressedCap === arrivingCap;
56602
+ if (arrivalAskedFor && arrivingSide.autoFocus !== false) {
56543
56603
  const found = findFocusTarget(arrivingSlot, {
56544
56604
  restoreMayClaim: true
56545
56605
  });
@@ -56549,13 +56609,14 @@ const focusWithTheFloor = (arrivingSlot, arrivingSide, arrivingCap) => {
56549
56609
  }
56550
56610
  }
56551
56611
  // Whatever the leaving slot held is inert and off the window now, so the
56552
- // browser dropped its focus to the document body: it has to land somewhere,
56553
- // and the cap of the side taking over is where the gesture was.
56612
+ // browser dropped its focus to the document body (Safari never gave it to
56613
+ // the pressed button in the first place): it has to land somewhere, and the
56614
+ // cap pressed is where the gesture was.
56554
56615
  const {
56555
56616
  activeElement
56556
56617
  } = document;
56557
56618
  if (!activeElement || activeElement === document.body) {
56558
- moveFocusTo(arrivingCap);
56619
+ moveFocusTo(pressedCap || arrivingCap);
56559
56620
  }
56560
56621
  };
56561
56622
 
@@ -67553,7 +67614,7 @@ const useDialogProps = props => {
67553
67614
  if (isTopLayer && themeColor !== false) {
67554
67615
  addCleanup(pushPopupThemeColor({
67555
67616
  themeColor,
67556
- backdropColor: backdrop ? getComputedStyle(dialogEl, "::backdrop").backgroundColor : null,
67617
+ backdropColor: backdrop ? readBackdropColor(dialogEl) : null,
67557
67618
  surfaceColor: flushEdges.top ? getComputedStyle(dialogEl).backgroundColor : null
67558
67619
  }));
67559
67620
  }
@@ -69320,7 +69381,7 @@ const usePopoverProps = props => {
69320
69381
  if (isTopLayer && themeColor !== false) {
69321
69382
  addCleanup(pushPopupThemeColor({
69322
69383
  themeColor,
69323
- backdropColor: backdropEl ? getComputedStyle(backdropEl).backgroundColor : null
69384
+ backdropColor: backdropEl ? readBackdropColor(backdropEl) : null
69324
69385
  }));
69325
69386
  }
69326
69387
  const cancelOpenInteractionSuppression = !silent && hasCssTransitionAnimation ? suppressPointerEventsDuringTransition(popoverEl) : null;