@jsenv/navi 0.29.320 → 0.29.322

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.
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { installImportMetaCssBuild, windowHeightSignal, windowWidthSignal, visualViewportHeightSignal, visualViewportWidthSignal, getAppHeight, getAppWidth, coarsePointerSignal, smallTouchScreenSignal } from "./jsenv_navi_side_effects.js";
6
6
  export { disableVirtualKeyboardOverlay } from "./jsenv_navi_side_effects.js";
7
- import { elementIsFocusable, createIterableWeakSet, dispatchInternalCustomEvent, dispatchCustomEvent, getVisuallyVisibleInfo, getFirstVisuallyVisibleAncestor, getElementSignature, createPubSub, findEvent, createValueEffect, findFocusDelegateTarget, findFocusable, scrollIntoViewThroughScrollables, allowWheelThrough, dispatchPublicCustomEvent, resolveCSSColor, ELEMENT_SIZE_CHANGE, findSelfOrAncestorFixedPosition, visibleRectEffect, pickPositionRelativeTo, getBorderSizes, getPaddingSizes, applyNewPosition, measureLongestVisualLineWidth, chainEvent, keepTouchRefusable, isPressDrivenClick, waitForTap, waitForPressHeld, suppressClickAfterGesture, startDragToTravel, markDragSource, refuseDragTo, startDragTo, installPanZoom, createEventGroupLogger, getKeyboardEventDefaultAction, activeElementSignal, normalizeStyle, mergeOneStyle, getPositionedParent, normalizeStyles, createGroupTransitionController, getBorderRadius, preventIntermediateScrollbar, createOpacityTransition, watchWheelTravel, scrollRoomTowards, getScrollContainer, isTouchDrivenEvent, scrollIntoViewScoped, closestOpenableAncestor, isAncestorOpen, isDisplayedDespiteClosedAncestor, observeAncestorOpenState, getAncestorOpenType, findBefore, findAfter, resolveCSSSize, hasCSSSizeUnit, releaseWheelGesture, getScrollIntoViewScopedOffsets, wheelGestureIsTakenFrom, claimWheelGesture, initFocusGroup, stringifyStyle as stringifyStyle$1, resolveOklchLightness, contrastColor, parsePositionArea, snapToPixel, trapFocusInside, trapScrollInside, getVirtualKeyboardOverlayHeight, onAncestorReopen, isPressDisputedByDrag, canScroll, measureWidestChildRow, performTabNavigation, dragAfterIntent, stickyAsRelativeCoords, createDragToMoveGestureController, getDropTargetInfo, setStyles, useActiveElement } from "@jsenv/dom";
7
+ import { elementIsFocusable, createIterableWeakSet, dispatchInternalCustomEvent, dispatchCustomEvent, getVisuallyVisibleInfo, getFirstVisuallyVisibleAncestor, getElementSignature, createPubSub, findEvent, createValueEffect, findFocusDelegateTarget, findFocusable, scrollIntoViewThroughScrollables, allowWheelThrough, dispatchPublicCustomEvent, resolveCSSColor, ELEMENT_SIZE_CHANGE, findSelfOrAncestorFixedPosition, visibleRectEffect, pickPositionRelativeTo, getBorderSizes, getPaddingSizes, applyNewPosition, measureLongestVisualLineWidth, chainEvent, keepTouchRefusable, isPressDrivenClick, waitForTap, waitForPressHeld, suppressClickAfterGesture, startDragToTravel, dragSourceThatStoodDown, markDragSource, refuseDragTo, startDragTo, installPanZoom, createEventGroupLogger, getKeyboardEventDefaultAction, activeElementSignal, normalizeStyle, mergeOneStyle, getPositionedParent, normalizeStyles, createGroupTransitionController, getBorderRadius, preventIntermediateScrollbar, createOpacityTransition, watchWheelTravel, scrollRoomTowards, getScrollContainer, isTouchDrivenEvent, scrollIntoViewScoped, closestOpenableAncestor, isAncestorOpen, isDisplayedDespiteClosedAncestor, observeAncestorOpenState, getAncestorOpenType, findBefore, findAfter, resolveCSSSize, hasCSSSizeUnit, releaseWheelGesture, getScrollIntoViewScopedOffsets, wheelGestureIsTakenFrom, claimWheelGesture, initFocusGroup, stringifyStyle as stringifyStyle$1, resolveOklchLightness, contrastColor, parsePositionArea, snapToPixel, trapFocusInside, trapScrollInside, getVirtualKeyboardOverlayHeight, onAncestorReopen, isPressDisputedByDrag, canScroll, measureWidestChildRow, performTabNavigation, dragAfterIntent, stickyAsRelativeCoords, createDragToMoveGestureController, getDropTargetInfo, setStyles, useActiveElement } from "@jsenv/dom";
8
8
  export { chainEvent, clickIsSuppressed, contrastColor, createDragGestureController, dragAfterIntent, findEvent, markDragSource, startDragTo } from "@jsenv/dom";
9
9
  import { signal, computed, effect, untracked, batch, useComputed, useSignal } from "@preact/signals";
10
10
  import { isValidElement, createContext, render, h, toChildArray, options, cloneElement, Fragment as Fragment$1 } from "preact";
@@ -10911,7 +10911,17 @@ defineInteractionDetector({
10911
10911
  },
10912
10912
  });
10913
10913
  }
10914
- if (hasLongPress) {
10914
+ // A press on something INSIDE this element that is picked up and
10915
+ // carried is that thing's, the same nearer word as the inner hold below:
10916
+ // a finger held still on a piece is the piece's own hold when it drags
10917
+ // by holding, and when it drags by distance it has decided nothing yet
10918
+ // at the delay — a hold answered there is a hold on a piece, and a carry
10919
+ // out of the same press the moment the hand moves. A surface that pans
10920
+ // steps back from the same source at the press (see pan_zoom.js).
10921
+ if (
10922
+ hasLongPress &&
10923
+ !isPressOnDragSourceInside(pointerDownEvent, element)
10924
+ ) {
10915
10925
  // A hold declared INSIDE this element, on this same press: the nearer
10916
10926
  // one answers, the way a click is the innermost target's, and this
10917
10927
  // wait is given up — two sheets opening from one hold is nobody's
@@ -11091,6 +11101,23 @@ const startSwipe = (
11091
11101
  });
11092
11102
  };
11093
11103
 
11104
+ // Whether the press landed on a drag source strictly inside the element — the
11105
+ // element itself being one is the other arrangement, where the grab answers
11106
+ // the hold (see refuseDragTo in @jsenv/dom). A source that stood down from this
11107
+ // press carries nothing, so it is no reason to hold back, and the walk goes on
11108
+ // above it the way a surface's does.
11109
+ const isPressOnDragSourceInside = (pointerDownEvent, element) => {
11110
+ const target = pointerDownEvent.target;
11111
+ if (!target || typeof target.closest !== "function") {
11112
+ return false;
11113
+ }
11114
+ let source = target.closest("[data-drag-source]");
11115
+ if (source && source === dragSourceThatStoodDown(pointerDownEvent)) {
11116
+ source = source.parentElement?.closest("[data-drag-source]") || null;
11117
+ }
11118
+ return Boolean(source) && source !== element && element.contains(source);
11119
+ };
11120
+
11094
11121
  // Whether a press landing now completes the tap before it: the same hand, soon
11095
11122
  // enough, and near enough. Axis by axis rather than as a distance, the way every
11096
11123
  // other slop in this family is read.
@@ -35856,6 +35883,8 @@ const createDisplayedEvent = (ancestor, becauseAncestorOpened) => {
35856
35883
  * @returns {Function} triggerAutofocus — can be called manually with a synthetic
35857
35884
  * event to re-run the focus logic outside of the layout-effect lifecycle.
35858
35885
  */
35886
+ const NO_ELEMENT_REF = { current: null };
35887
+
35859
35888
  const useAutoFocus = (
35860
35889
  focusableElementRef,
35861
35890
  autoFocus,
@@ -35989,8 +36018,15 @@ const useAutoFocus = (
35989
36018
  };
35990
36019
  };
35991
36020
 
36021
+ // Nothing to place when the control asks for no focus ("restore" is given
36022
+ // focus by a transfer, never by this effect): the displayed-effect is then
36023
+ // handed no element at all, so it never asks the layout whether one is on
36024
+ // screen — a question every control in a list would otherwise ask at
36025
+ // mount, for an answer this hook would not use. Read at mount, like the
36026
+ // deps below say.
36027
+ const claimsFocus = Boolean(autoFocus) && autoFocus !== "restore";
35992
36028
  useDisplayedLayoutEffect(
35993
- focusableElementRef,
36029
+ claimsFocus ? focusableElementRef : NO_ELEMENT_REF,
35994
36030
  (el, e) => {
35995
36031
  return triggerAutofocus(e);
35996
36032
  },