foldkit-primitives 0.15.0 → 0.15.2

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.
@@ -233,6 +233,14 @@ export declare const FLUID_HOVER_ATTRIBUTE = "data-fluid-hover";
233
233
  export declare const FLUID_PRESS_ATTRIBUTE = "data-fluid-press";
234
234
  /** The attribute on the item the highlight is shown on, for what CSS draws beside it. */
235
235
  export declare const FLUID_LIT_ATTRIBUTE = "data-fluid-lit";
236
+ /**
237
+ * The attribute `FluidHover` sets on its container, to the highlight's name,
238
+ * while the item that highlight is on is held. A stylist draws the press on
239
+ * the highlight (`data-fluid-held`) rather than on the item, whose own press
240
+ * is hidden under it; a press in a gap marks it too where `gapClick` sends
241
+ * that press to the lit item.
242
+ */
243
+ export declare const FLUID_HELD_ATTRIBUTE = "data-fluid-held";
236
244
  declare const Axis: Schema.Literals<readonly ["x", "y", "xy"]>;
237
245
  export type FluidAxis = typeof Axis.Type;
238
246
  /**
@@ -263,7 +271,7 @@ export type FluidAxis = typeof Axis.Type;
263
271
  * tries again for three frames, rather than drawing the highlight at zero.
264
272
  * The item the highlight is shown on carries `data-fluid-lit`, so a style
265
273
  * can change what sits beside it (a table hides the lines around the lit
266
- * row).
274
+ * row); its container carries `data-fluid-held` while that item is pressed.
267
275
  *
268
276
  * `follows` names the item the highlight sits on while the pointer is not
269
277
  * moving it: a menu marks the row its keys reach (`[data-active]`), and the
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/dom/autofocus.ts","../../src/dom/clipboard.ts","../../src/dom/input-mask.ts","../../src/dom/keep-in-view.ts","../../src/dom/script-loader.ts","../../src/dom/share.ts","../../src/dom/measure.ts","../../src/dom/follow-tab-stop.ts","../../src/dom/scroll.ts","../../src/dom/pointed-links.ts","../../src/dom/fluid-hover.ts","../../src/dom/keyboard-inset.ts","../../src/dom/scroll-bars.ts","../../src/dom/swipe.ts","../../src/dom/scroll-settle.ts","../../src/d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GA,aAAU;WAEnB;WACA;WACA;WACA;WACA;;;qBAIS,eAAa,OAAA;;;;YAId,uBAAuB,cAAc;;;;;;;qBAQpC,eAAY,eAAiB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiC5C,UAAQ,MAAA;;;;;;;;;;;;qBCnDR,8CAAkB;;IAClB,KAAG,OAAA;;;IACE,KAAG,OAAA;IAAiB,SAAO,OAAA;;;YAEjC,4BAA4B,mBAAmB;;iBAG1C;WACN;WACA;WACA;;;;;;;;;qBAUE,cAAW,QAAY,gBAAc,QAAQ"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/dom/autofocus.ts","../../src/dom/clipboard.ts","../../src/dom/input-mask.ts","../../src/dom/keep-in-view.ts","../../src/dom/script-loader.ts","../../src/dom/share.ts","../../src/dom/measure.ts","../../src/dom/follow-tab-stop.ts","../../src/dom/scroll.ts","../../src/dom/pointed-links.ts","../../src/dom/fluid-hover.ts","../../src/dom/keyboard-inset.ts","../../src/dom/scroll-bars.ts","../../src/dom/swipe.ts","../../src/dom/scroll-settle.ts","../../src/dom/pointer-position.ts","../../src/dom/track-box.ts","../../src/dom/image-decode.ts"],"mappings":";;;;;;qBAGa,SAAO,OAAA;YACR,iBAAiB,QAAQ;;;;;;;;qBASxB,WAAS,MAAA;;;;;qBCJT,4CAAgB;;;IAEb,SAAO,OAAA;;;YAEX,0BAA0B,iBAAiB;qBAE1C,gDAAoB;;IACvB,MAAI,OAAA;;;IACE,SAAO,OAAA;;;YAEX,8BAA8B,qBAAqB;;;;;;qBAUlD,WAAQ,iBAAmB,QAAQ;;;;;qBAsBnC,gBAAe,QAAQ;;;;qBC/CvB,OAAK,OAAA;;;;YAIN,eAAe,MAAM;;;;;;;qBAiCpB,YAAS,eACP;WAED;WAAyB;;;;;;;;;;;qBA6C1B,WAAS,MAAA;WAAT,OAAA;;;;;;;;;;;;;;;;;qBC7EA,YAAU,MAAA;;YAAV,OAAA;;;;qBCDA,yCAAa;;;IAEV,S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;;;;;;;;;qBAoCJ,OAAK,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBCtIL,eAAa,OAAA;;kBAAb,OAAA;;YAID,uBAAuB,cAAc;;qBAGpC;;;;;;;;;;;;;qBAcA,cAAY,MAAA;;;;;;;;;;;;;;;;;;;qBCfZ,cAAY,OAAA;;;;;YAKb,sBAAsB,aAAa;qBAKlC,gBAAc,OAAA;;;;;;;;;;;YAMf,wBAAwB,eAAe;qBAEtC,cAAY,OAAA;;;;;;;;;;;;;;;;;;;;YAWb,sBAAsB,aAAa;qBAElC,iBAAe,OAAA;;sBAAf,OAAA;;YAID,yBAAyB,gBAAgB;YAEzC,cAAc,iBAAiB,eAAe;UAEhD;WACC;WACA;WACA;WACA;;iBAGM;WACN;WACA;WACA;WACA;;;;;;;;qBASE,eAAY;WAAuB,MAAM;WAAe,QAAQ;MAAU;;;;;;;;qBAwB1E,oBAAiB,SAAa,YAAU;;;;;;;;;;;;;;;qBA0BxC,iBAAe,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBClHf;;qBAGA,aAAU;WAEnB;WACA;WACA;WACA;WACA;;;qBAIS,eAAa,OAAA;;;;YAId,uBAAuB,cAAc;;;;;;;qBAQpC,eAAY,eAAiB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;qBAiC5C,UAAQ,MAAA;;;;;;;;;;;;qBCnDR,8CAAkB;;IAClB,KAAG,OAAA;;;IACE,KAAG,OAAA;IAAiB,SAAO,OAAA;;;YAEjC,4BAA4B,mBAAmB;;iBAG1C;WACN;WACA;WACA;;;;;;;;;qBAUE,cAAW,QAAY,gBAAc,QAAQ"}
@@ -583,6 +583,14 @@ const FLUID_HOVER_ATTRIBUTE = "data-fluid-hover";
583
583
  const FLUID_PRESS_ATTRIBUTE = "data-fluid-press";
584
584
  /** The attribute on the item the highlight is shown on, for what CSS draws beside it. */
585
585
  const FLUID_LIT_ATTRIBUTE = "data-fluid-lit";
586
+ /**
587
+ * The attribute `FluidHover` sets on its container, to the highlight's name,
588
+ * while the item that highlight is on is held. A stylist draws the press on
589
+ * the highlight (`data-fluid-held`) rather than on the item, whose own press
590
+ * is hidden under it; a press in a gap marks it too where `gapClick` sends
591
+ * that press to the lit item.
592
+ */
593
+ const FLUID_HELD_ATTRIBUTE = "data-fluid-held";
586
594
  const Axis = Schema.Literals([
587
595
  "x",
588
596
  "y",
@@ -625,7 +633,7 @@ const isDisabled = (item) => item.matches("[aria-disabled=\"true\"], [data-disab
625
633
  * tries again for three frames, rather than drawing the highlight at zero.
626
634
  * The item the highlight is shown on carries `data-fluid-lit`, so a style
627
635
  * can change what sits beside it (a table hides the lines around the lit
628
- * row).
636
+ * row); its container carries `data-fluid-held` while that item is pressed.
629
637
  *
630
638
  * `follows` names the item the highlight sits on while the pointer is not
631
639
  * moving it: a menu marks the row its keys reach (`[data-active]`), and the
@@ -707,6 +715,7 @@ const FluidHover = Mount.defineStream("FluidHover", {
707
715
  };
708
716
  const hide = () => {
709
717
  container.style.setProperty(property.shown, "0");
718
+ container.removeAttribute(FLUID_HELD_ATTRIBUTE);
710
719
  light(null);
711
720
  };
712
721
  /** Whether the keyboard has an item focused, which the highlight then stays on. */
@@ -744,6 +753,7 @@ const FluidHover = Mount.defineStream("FluidHover", {
744
753
  };
745
754
  const leave = () => {
746
755
  pointer = null;
756
+ release();
747
757
  if (!keyed()) hide();
748
758
  };
749
759
  const focus = (event) => {
@@ -755,19 +765,37 @@ const FluidHover = Mount.defineStream("FluidHover", {
755
765
  const to = event.relatedTarget;
756
766
  if (pointer === null && !(to instanceof Node && container.contains(to))) hide();
757
767
  };
768
+ const reachOf = (item, event) => gapReach === void 0 || distance(item.getBoundingClientRect(), event.clientX, event.clientY, "xy") <= gapReach;
769
+ /** Whether a click in a gap presses the lit item, within `gapReach` of it. */
770
+ const reaches = (item, event) => gapClick && reachOf(item, event);
758
771
  const click = (event) => {
759
- if (!gapClick || active === null) return;
772
+ if (active === null) return;
760
773
  if (container.style.getPropertyValue(property.shown) !== "1") return;
761
774
  const target = event.target;
762
775
  if (!(target instanceof Element) || target.closest(selector) !== null) return;
763
- const reach = distance(active.getBoundingClientRect(), event.clientX, event.clientY, "xy");
764
- if (gapReach !== void 0 && reach > gapReach) return;
776
+ if (!reaches(active, event)) return;
765
777
  const press = active.querySelector(`[data-fluid-press]`) ?? active;
766
778
  if (press instanceof HTMLElement) press.click();
767
779
  };
768
780
  const soon = () => {
769
781
  if (active !== null) requestAnimationFrame(() => place());
770
782
  };
783
+ /**
784
+ * Marks the container as held where the press is the lit item's: the
785
+ * item itself, or a gap a click there reaches through (`gapClick`). A
786
+ * press on another item is that item's, once the pointer has lit it.
787
+ */
788
+ const press = (event) => {
789
+ if (event.button !== 0 || active === null) return;
790
+ if (container.style.getPropertyValue(property.shown) !== "1") return;
791
+ const target = event.target;
792
+ if (!(target instanceof Element)) return;
793
+ const inItem = target.closest(selector) !== null;
794
+ if (inItem && !active.contains(target)) return;
795
+ if (!inItem && !reaches(active, event)) return;
796
+ container.setAttribute(FLUID_HELD_ATTRIBUTE, name);
797
+ };
798
+ const release = () => container.removeAttribute(FLUID_HELD_ATTRIBUTE);
771
799
  /** The marked item moved: the highlight goes with it, or fades if it is gone. */
772
800
  const marked = () => {
773
801
  if (follows === void 0) return;
@@ -786,7 +814,10 @@ const FluidHover = Mount.defineStream("FluidHover", {
786
814
  attributes: true
787
815
  });
788
816
  container.addEventListener("pointermove", move, { passive: true });
817
+ container.addEventListener("pointerdown", press);
789
818
  container.addEventListener("pointerleave", leave);
819
+ window.addEventListener("pointerup", release);
820
+ window.addEventListener("pointercancel", release);
790
821
  container.addEventListener("focusin", focus);
791
822
  container.addEventListener("focusout", blur);
792
823
  container.addEventListener("click", click);
@@ -800,9 +831,13 @@ const FluidHover = Mount.defineStream("FluidHover", {
800
831
  sizes?.disconnect();
801
832
  marks?.disconnect();
802
833
  container.removeAttribute(FLUID_HOVER_ATTRIBUTE);
834
+ container.removeAttribute(FLUID_HELD_ATTRIBUTE);
803
835
  light(null);
804
836
  container.removeEventListener("pointermove", move);
837
+ container.removeEventListener("pointerdown", press);
805
838
  container.removeEventListener("pointerleave", leave);
839
+ window.removeEventListener("pointerup", release);
840
+ window.removeEventListener("pointercancel", release);
806
841
  container.removeEventListener("focusin", focus);
807
842
  container.removeEventListener("focusout", blur);
808
843
  container.removeEventListener("click", click);
@@ -1817,6 +1852,6 @@ const decodeImage = (source) => ({
1817
1852
  })
1818
1853
  });
1819
1854
  //#endregion
1820
- export { Autofocus, ClipboardMessage, ClipboardReadMessage, DRAG_THRESHOLD, DragCancelled, DragDropped, DragPlace, DragStarted, DragZone, DraggedOver, EditAsked, EditableText, FLUID_HOVER_ATTRIBUTE, FLUID_LIT_ATTRIBUTE, FLUID_PRESS_ATTRIBUTE, FluidHover, FocusScope, Focused, FollowTabStop, HOLD_SLOP, HOLD_TO_DRAG_MS, HideOutside, ImageDecodeMessage, Input, InputMask, KEYBOARD_INSET, KeepInView, KeyboardInset, Measure, Move, MoveEnded, MoveStarted, Moved, NO_SWIPE, PointerDrag, PointerMoved, PointerPoint, PointerPosition, PointerPressed, PointerReleased, SCROLL_BAR_ATTRIBUTE, SCROLL_OVERLAID_ATTRIBUTE, SETTLE_QUIET, SWIPE_WINDOW, ScriptMessage, ScrollBars, ScrollLock, ScrollSettle, ScrollSettled, ShareData, ShareMessage, Swipe, SwipeEnded, SwipeStarted, Swiped, TRACK_TARGET_ATTRIBUTE, TargetHovered, TargetPressed, Targets, TextCancelled, TextCommitted, TextEdited, TrackBox, TrackedTarget, applyMask, boxOf, canScroll, copyText, cornerRadius, decodeImage, fluidHovered, keepScroll, keyboardInset, loadScript, measurePaddingBox, measured, paddingBoxOf, pointedLinks, readText, scrollThumb, share, tabbableWithin, targetOf, textOf, trackedBox, velocityOf, zoneOf };
1855
+ export { Autofocus, ClipboardMessage, ClipboardReadMessage, DRAG_THRESHOLD, DragCancelled, DragDropped, DragPlace, DragStarted, DragZone, DraggedOver, EditAsked, EditableText, FLUID_HELD_ATTRIBUTE, FLUID_HOVER_ATTRIBUTE, FLUID_LIT_ATTRIBUTE, FLUID_PRESS_ATTRIBUTE, FluidHover, FocusScope, Focused, FollowTabStop, HOLD_SLOP, HOLD_TO_DRAG_MS, HideOutside, ImageDecodeMessage, Input, InputMask, KEYBOARD_INSET, KeepInView, KeyboardInset, Measure, Move, MoveEnded, MoveStarted, Moved, NO_SWIPE, PointerDrag, PointerMoved, PointerPoint, PointerPosition, PointerPressed, PointerReleased, SCROLL_BAR_ATTRIBUTE, SCROLL_OVERLAID_ATTRIBUTE, SETTLE_QUIET, SWIPE_WINDOW, ScriptMessage, ScrollBars, ScrollLock, ScrollSettle, ScrollSettled, ShareData, ShareMessage, Swipe, SwipeEnded, SwipeStarted, Swiped, TRACK_TARGET_ATTRIBUTE, TargetHovered, TargetPressed, Targets, TextCancelled, TextCommitted, TextEdited, TrackBox, TrackedTarget, applyMask, boxOf, canScroll, copyText, cornerRadius, decodeImage, fluidHovered, keepScroll, keyboardInset, loadScript, measurePaddingBox, measured, paddingBoxOf, pointedLinks, readText, scrollThumb, share, tabbableWithin, targetOf, textOf, trackedBox, velocityOf, zoneOf };
1821
1856
 
1822
1857
  //# sourceMappingURL=index.mjs.map