@jsenv/dom 0.17.28 → 0.17.29

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +44 -13
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -9484,7 +9484,9 @@ const css$4 = /* css */`
9484
9484
  touch-action: pinch-zoom;
9485
9485
  }
9486
9486
  [data-drag-ignore],
9487
- [data-own-target] {
9487
+ [data-own-target],
9488
+ [data-drag-source] [popover],
9489
+ [data-drag-source] dialog {
9488
9490
  -webkit-touch-callout: default;
9489
9491
  touch-action: auto;
9490
9492
  }
@@ -11926,7 +11928,8 @@ const css$1 = /* css */`
11926
11928
  whoever puts the drag there asks for the hand when a grab really is the
11927
11929
  first thing the element offers.
11928
11930
  An opted-out area keeps both its cursor and its selection, and never starts
11929
- a drag (see the check in startDragTo).
11931
+ a drag (see the check in startDragTo); a popover or a dialog anchored in a
11932
+ source is one without having to say so.
11930
11933
  Controls inside a source keep their own cursor: cursor is inherited, and
11931
11934
  anything setting its own (a button's pointer) wins on itself.
11932
11935
  Only the resting cursor is set here: what it becomes once a drag is under
@@ -11939,7 +11942,9 @@ const css$1 = /* css */`
11939
11942
  cursor: default;
11940
11943
  }
11941
11944
  [data-drag-ignore],
11942
- [data-own-target] {
11945
+ [data-own-target],
11946
+ [data-drag-source] [popover],
11947
+ [data-drag-source] dialog {
11943
11948
  cursor: auto;
11944
11949
  }
11945
11950
 
@@ -12039,8 +12044,12 @@ import.meta.css = [css$1, "@jsenv/dom/src/interaction/drag/drag_to.js"];
12039
12044
  // control that reads the pointer itself. `data-own-target` is the same fact said
12040
12045
  // once for every gesture there is: an element declaring that a press landing on
12041
12046
  // it is aimed AT it, whatever it happens to sit inside (see also
12042
- // DRAG_EXCLUDED_SELECTOR in drag_to_travel.js).
12043
- const DRAG_IGNORED_SELECTOR = "[data-drag-ignore],[data-own-target]";
12047
+ // DRAG_EXCLUDED_SELECTOR in drag_to_travel.js). A popover or a dialog says it
12048
+ // without being asked: it is a layer OVER the surface, so a press in it is aimed
12049
+ // at the layer — yet it stays a descendant of whatever it is anchored in (a
12050
+ // callout next to a button, in the card that carries both), and the press
12051
+ // bubbles through the surface as if it had landed on it.
12052
+ const DRAG_IGNORED_SELECTOR = "[data-drag-ignore],[data-own-target],[popover],dialog";
12044
12053
 
12045
12054
  /**
12046
12055
  * Starts a drag-to-reorder interaction on a list item.
@@ -12540,8 +12549,8 @@ const startDragTo = (event, effects, {
12540
12549
  ...options
12541
12550
  } = {}) => {
12542
12551
  // An area that opted out of dragging (a text one wants to select, a control that
12543
- // owns the gesture): the press there is none of our business.
12544
- if (event.target.closest && event.target.closest(DRAG_IGNORED_SELECTOR)) {
12552
+ // owns the gesture, a callout): the press there is none of our business.
12553
+ if (isPressIgnored(event.target, draggedElement)) {
12545
12554
  return undefined;
12546
12555
  }
12547
12556
  // A secondary button (right click and friends) is a context menu, not a grab.
@@ -12722,8 +12731,8 @@ const startDragToCarryCopy = (event, {
12722
12731
  ...options
12723
12732
  }) => {
12724
12733
  // An area that opted out of dragging (a text one wants to select, a control
12725
- // that owns the gesture): the press there is none of our business.
12726
- if (event.target.closest && event.target.closest(DRAG_IGNORED_SELECTOR)) {
12734
+ // that owns the gesture, a callout): the press there is none of our business.
12735
+ if (isPressIgnored(event.target, draggedElement)) {
12727
12736
  return undefined;
12728
12737
  }
12729
12738
  // A secondary button (right click and friends) is a context menu, not a grab.
@@ -13231,6 +13240,18 @@ const createDragClone = (element, pointerEvent) => {
13231
13240
  return wrapper;
13232
13241
  };
13233
13242
 
13243
+ // The nearest word about the press wins: an opted-out area INSIDE the dragged
13244
+ // element takes the press away from it, one AROUND it does not — a list
13245
+ // reordered inside a dialog, or a dialog carried by its own handle, is itself the
13246
+ // last thing said before the finger.
13247
+ const isPressIgnored = (target, draggedElement) => {
13248
+ if (!target.closest) {
13249
+ return false;
13250
+ }
13251
+ const ignored = target.closest(DRAG_IGNORED_SELECTOR);
13252
+ return Boolean(ignored) && !ignored.contains(draggedElement);
13253
+ };
13254
+
13234
13255
  const startDragToResizeGesture = (
13235
13256
  pointerdownEvent,
13236
13257
  { onDragStart, onDrag, onRelease, ...options },
@@ -13471,8 +13492,10 @@ const DRAG_RESISTANCE = 0.3;
13471
13492
  // place whose only purpose is to be taken hold of, from the first pixel. And so
13472
13493
  // is an OWN TARGET: an element saying a press landing on it is aimed at IT,
13473
13494
  // which is the same sentence said to every gesture at once rather than to this
13474
- // one (see DRAG_IGNORED_SELECTOR in drag_to.js).
13475
- const DRAG_EXCLUDED_SELECTOR = ["input", "textarea", "select", '[contenteditable=""]', '[contenteditable="true"]', "[data-drag-handle]", "[data-no-drag-travel]", "[data-own-target]"].join(",");
13495
+ // one (see DRAG_IGNORED_SELECTOR in drag_to.js). And so is a popover or a
13496
+ // dialog: a layer OVER the box, whose press only bubbles through the box because
13497
+ // the layer is anchored in it.
13498
+ const DRAG_EXCLUDED_SELECTOR = ["input", "textarea", "select", '[contenteditable=""]', '[contenteditable="true"]', "[data-drag-handle]", "[data-no-drag-travel]", "[data-own-target]", "[popover]", "dialog"].join(",");
13476
13499
 
13477
13500
  // Which axes a box travels on, one attribute per gesture, said in the DOM by
13478
13501
  // whoever owns the box: it is what a box ABOVE another reads to know the
@@ -13698,7 +13721,7 @@ const startDragToTravel = (pointerDownEvent, {
13698
13721
  onGiveUp = () => {}
13699
13722
  }) => {
13700
13723
  const target = pointerDownEvent.target;
13701
- if (!target.closest || target.closest(DRAG_EXCLUDED_SELECTOR)) {
13724
+ if (!target.closest || isPressExcluded(target, element)) {
13702
13725
  return null;
13703
13726
  }
13704
13727
  // A box between the finger and this one that travels the same way, and then
@@ -14159,7 +14182,7 @@ const watchWheelTravel = (element, {
14159
14182
  const {
14160
14183
  target
14161
14184
  } = wheelEvent;
14162
- if (target.closest && target.closest(DRAG_EXCLUDED_SELECTOR) || scrollRoomTowards(target, element, axis, sign) ||
14185
+ if (target.closest && isPressExcluded(target, element) || scrollRoomTowards(target, element, axis, sign) ||
14163
14186
  // …plus the third: a box below this one that travels on this axis. Its
14164
14187
  // watcher hears the same wheel event this one does — they all listen at
14165
14188
  // the document — so without this both step, and one push moves two
@@ -14250,6 +14273,14 @@ const watchWheelTravel = (element, {
14250
14273
  };
14251
14274
  };
14252
14275
 
14276
+ // The nearest word wins: what is excluded INSIDE the box takes the press away
14277
+ // from it, what is around the box does not — a docked dialog IS the box that
14278
+ // travels, and being a dialog is no reason for it to refuse its own press.
14279
+ const isPressExcluded = (target, element) => {
14280
+ const excluded = target.closest(DRAG_EXCLUDED_SELECTOR);
14281
+ return Boolean(excluded) && !excluded.contains(element);
14282
+ };
14283
+
14253
14284
  // Shared by navi's own use_displayed_layout_effect.js (rich "navi_displayed"
14254
14285
  // CustomEvent, open transitions only) and visible_rect.js (needs both
14255
14286
  // directions: hide when a container closes, recheck when it reopens) — the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.28",
3
+ "version": "0.17.29",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {