@jsenv/navi 0.29.468 → 0.29.470

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.
@@ -46639,8 +46639,10 @@ const createControlInfo = (props, {
46639
46639
  } else if (controlType === "details") {
46640
46640
  statePropName = "open";
46641
46641
  defaultStatePropName = "defaultOpen";
46642
- stateInitial = props.open || props.defaultOpen;
46643
46642
  value = props.value || "open";
46643
+ // Held like a checkbox: the value while open, nothing while closed — the
46644
+ // shape the toggle writes back (see details.jsx).
46645
+ stateInitial = props.open || props.defaultOpen ? value : undefined;
46644
46646
  } else if (controlType === "picker" || controlType === "select") {
46645
46647
  statePropName = "value";
46646
46648
  defaultStatePropName = "defaultValue";
@@ -54674,6 +54676,9 @@ const DetailsField = props => {
54674
54676
  value,
54675
54677
  children
54676
54678
  } = detailsProps;
54679
+ const {
54680
+ uiStateController
54681
+ } = controlChildrenWrapperProps;
54677
54682
  const open = Boolean(value);
54678
54683
  useFocusGroup(ref, {
54679
54684
  enabled: focusGroup,
@@ -54755,6 +54760,10 @@ const DetailsField = props => {
54755
54760
  return;
54756
54761
  }
54757
54762
  const details = ref.current;
54763
+ // The browser has already toggled the element (a summary press, the
54764
+ // arrow shortcuts): the state follows it whatever the gate says, or the
54765
+ // marker and whoever reads the value keep the old one.
54766
+ uiStateController.setUIState(details.open ? uiStateController.value : undefined, e);
54758
54767
  dispatchRequestInteraction(details, {
54759
54768
  event: e,
54760
54769
  wantAction: true,
@@ -77400,6 +77409,13 @@ const useListScrollSync = ({
77400
77409
  // the selected item for as long as the hold takes to put it back.
77401
77410
  return;
77402
77411
  }
77412
+ if (getScroller() === document.scrollingElement) {
77413
+ // Where the document opens is the arrival's (see scroll_restoration.js),
77414
+ // and a list asks for a place in it through `defaultScrolled`. A box
77415
+ // around the list (a popup's body) has no other owner, so the selected
77416
+ // item is still centered there.
77417
+ return;
77418
+ }
77403
77419
  const items = listItems.itemsSignal.peek();
77404
77420
  const firstSelected = items.find(i => {
77405
77421
  if (i.selected) {
@@ -85701,7 +85717,42 @@ const Spin = ({
85701
85717
  variant: "discrete",
85702
85718
  outlineWidth: group ? undefined : "0",
85703
85719
  textAlign: "center",
85704
- expandX: true,
85720
+ expandX: true
85721
+ // The arrow keys are the chevrons at the keyboard: one step the way
85722
+ // the spin steps (`valueAtStep`, round at the ends when it loops),
85723
+ // refused at a bound in the chevron's words. The field's own
85724
+ // stepping (input_resolver_mode) stands down on a prevented keydown.
85725
+ ,
85726
+ onKeyDown: e => {
85727
+ controlProps?.onKeyDown?.(e);
85728
+ if (e.defaultPrevented) {
85729
+ return;
85730
+ }
85731
+ if (e.key !== "ArrowUp" && e.key !== "ArrowDown") {
85732
+ return;
85733
+ }
85734
+ // Up is towards the bigger values however the spin lies: what a
85735
+ // field means by it, and what ▲ means on a NumberSpin.
85736
+ const isNext = e.key === "ArrowUp";
85737
+ if (!(isNext ? nextAllowed : previousAllowed)) {
85738
+ e.preventDefault();
85739
+ openCallout(boundMessage(isNext), {
85740
+ anchorElement: middleRef.current,
85741
+ status: "info",
85742
+ openingEvent: e
85743
+ });
85744
+ return;
85745
+ }
85746
+ dispatchRequestInteraction(e.currentTarget, {
85747
+ event: e,
85748
+ name: "--navi-arrow-up-down",
85749
+ prevented: () => e.preventDefault(),
85750
+ allowed: () => {
85751
+ setValue(isNext ? valueNext : valuePrevious, e);
85752
+ e.preventDefault();
85753
+ }
85754
+ });
85755
+ },
85705
85756
  uiAction: (valueNext, event) => {
85706
85757
  uiAction?.(valueNext, stepEventRef.current ?? event);
85707
85758
  }