@kumix/ui 0.3.6 → 0.3.7

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 (152) hide show
  1. package/dist/components/agents/ai-sidebar.d.ts +17 -1
  2. package/dist/components/agents/ai-sidebar.d.ts.map +1 -1
  3. package/dist/components/agents/ai-sidebar.js +90 -14
  4. package/dist/components/agents/ai-sidebar.js.map +1 -1
  5. package/dist/components/agents/chat-app.d.ts +10 -5
  6. package/dist/components/agents/chat-app.d.ts.map +1 -1
  7. package/dist/components/agents/chat-app.js +54 -5
  8. package/dist/components/agents/chat-app.js.map +1 -1
  9. package/dist/components/agents/citations.d.ts.map +1 -1
  10. package/dist/components/agents/citations.js +5 -6
  11. package/dist/components/agents/citations.js.map +1 -1
  12. package/dist/components/agents/tool-approval.d.ts.map +1 -1
  13. package/dist/components/agents/tool-approval.js +1 -1
  14. package/dist/components/agents/tool-approval.js.map +1 -1
  15. package/dist/components/motion/action-swap.d.ts.map +1 -1
  16. package/dist/components/motion/action-swap.js +2 -2
  17. package/dist/components/motion/action-swap.js.map +1 -1
  18. package/dist/components/motion/animated-sidebar.js +1 -0
  19. package/dist/components/motion/animated-sidebar.js.map +1 -1
  20. package/dist/components/motion/availability-scheduler/copy-menu.js +1 -1
  21. package/dist/components/motion/availability-scheduler/day-row.d.ts +5 -2
  22. package/dist/components/motion/availability-scheduler/day-row.d.ts.map +1 -1
  23. package/dist/components/motion/availability-scheduler/day-row.js +18 -8
  24. package/dist/components/motion/availability-scheduler/day-row.js.map +1 -1
  25. package/dist/components/motion/availability-scheduler/index.d.ts.map +1 -1
  26. package/dist/components/motion/availability-scheduler/index.js +27 -5
  27. package/dist/components/motion/availability-scheduler/index.js.map +1 -1
  28. package/dist/components/motion/availability-scheduler/time-select.d.ts +3 -1
  29. package/dist/components/motion/availability-scheduler/time-select.d.ts.map +1 -1
  30. package/dist/components/motion/availability-scheduler/time-select.js +3 -1
  31. package/dist/components/motion/availability-scheduler/time-select.js.map +1 -1
  32. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  33. package/dist/components/motion/bottom-sheet.js +2 -1
  34. package/dist/components/motion/bottom-sheet.js.map +1 -1
  35. package/dist/components/motion/command-palette.d.ts.map +1 -1
  36. package/dist/components/motion/command-palette.js +3 -1
  37. package/dist/components/motion/command-palette.js.map +1 -1
  38. package/dist/components/motion/context-menu.d.ts.map +1 -1
  39. package/dist/components/motion/context-menu.js +16 -6
  40. package/dist/components/motion/context-menu.js.map +1 -1
  41. package/dist/components/motion/cylinder-carousel.d.ts.map +1 -1
  42. package/dist/components/motion/cylinder-carousel.js +4 -3
  43. package/dist/components/motion/cylinder-carousel.js.map +1 -1
  44. package/dist/components/motion/expandable-action-bar.d.ts +6 -0
  45. package/dist/components/motion/expandable-action-bar.d.ts.map +1 -1
  46. package/dist/components/motion/expandable-action-bar.js +38 -9
  47. package/dist/components/motion/expandable-action-bar.js.map +1 -1
  48. package/dist/components/motion/hold-action-button.d.ts +1 -1
  49. package/dist/components/motion/hold-action-button.d.ts.map +1 -1
  50. package/dist/components/motion/hold-action-button.js +64 -50
  51. package/dist/components/motion/hold-action-button.js.map +1 -1
  52. package/dist/components/motion/morphing-tabs.d.ts.map +1 -1
  53. package/dist/components/motion/morphing-tabs.js +59 -18
  54. package/dist/components/motion/morphing-tabs.js.map +1 -1
  55. package/dist/components/motion/notification-stack.d.ts.map +1 -1
  56. package/dist/components/motion/notification-stack.js +28 -11
  57. package/dist/components/motion/notification-stack.js.map +1 -1
  58. package/dist/components/motion/popover-morph.d.ts.map +1 -1
  59. package/dist/components/motion/popover-morph.js +26 -11
  60. package/dist/components/motion/popover-morph.js.map +1 -1
  61. package/dist/components/motion/popover.d.ts.map +1 -1
  62. package/dist/components/motion/popover.js +39 -28
  63. package/dist/components/motion/popover.js.map +1 -1
  64. package/dist/components/motion/preview-rail.d.ts.map +1 -1
  65. package/dist/components/motion/preview-rail.js +42 -13
  66. package/dist/components/motion/preview-rail.js.map +1 -1
  67. package/dist/components/motion/pull-to-refresh.d.ts.map +1 -1
  68. package/dist/components/motion/pull-to-refresh.js +8 -7
  69. package/dist/components/motion/pull-to-refresh.js.map +1 -1
  70. package/dist/components/motion/range-slider-bubble.d.ts.map +1 -1
  71. package/dist/components/motion/range-slider-bubble.js +2 -1
  72. package/dist/components/motion/range-slider-bubble.js.map +1 -1
  73. package/dist/components/motion/range-slider-fluid.d.ts.map +1 -1
  74. package/dist/components/motion/range-slider-fluid.js +2 -1
  75. package/dist/components/motion/range-slider-fluid.js.map +1 -1
  76. package/dist/components/motion/range-slider-ruler.d.ts.map +1 -1
  77. package/dist/components/motion/range-slider-ruler.js +2 -1
  78. package/dist/components/motion/range-slider-ruler.js.map +1 -1
  79. package/dist/components/motion/range-slider-wave.d.ts.map +1 -1
  80. package/dist/components/motion/range-slider-wave.js +2 -1
  81. package/dist/components/motion/range-slider-wave.js.map +1 -1
  82. package/dist/components/motion/range-slider.d.ts.map +1 -1
  83. package/dist/components/motion/range-slider.js +2 -1
  84. package/dist/components/motion/range-slider.js.map +1 -1
  85. package/dist/components/motion/select.d.ts +15 -1
  86. package/dist/components/motion/select.d.ts.map +1 -1
  87. package/dist/components/motion/select.js +15 -4
  88. package/dist/components/motion/select.js.map +1 -1
  89. package/dist/components/motion/slide-action-button.d.ts.map +1 -1
  90. package/dist/components/motion/slide-action-button.js +3 -2
  91. package/dist/components/motion/slide-action-button.js.map +1 -1
  92. package/dist/components/motion/swipeable-list.d.ts.map +1 -1
  93. package/dist/components/motion/swipeable-list.js +2 -1
  94. package/dist/components/motion/swipeable-list.js.map +1 -1
  95. package/dist/components/motion/table/index.d.ts.map +1 -1
  96. package/dist/components/motion/table/index.js +64 -6
  97. package/dist/components/motion/table/index.js.map +1 -1
  98. package/dist/components/motion/table/table-header.d.ts.map +1 -1
  99. package/dist/components/motion/table/table-header.js +3 -2
  100. package/dist/components/motion/table/table-header.js.map +1 -1
  101. package/dist/components/motion/text-reveal.d.ts.map +1 -1
  102. package/dist/components/motion/text-reveal.js +72 -48
  103. package/dist/components/motion/text-reveal.js.map +1 -1
  104. package/dist/components/motion/tooltip.d.ts.map +1 -1
  105. package/dist/components/motion/tooltip.js +35 -15
  106. package/dist/components/motion/tooltip.js.map +1 -1
  107. package/dist/components/motion/wheel-picker.d.ts.map +1 -1
  108. package/dist/components/motion/wheel-picker.js +4 -3
  109. package/dist/components/motion/wheel-picker.js.map +1 -1
  110. package/dist/components/reui/badge.d.ts +1 -1
  111. package/dist/components/reui/icon-tile.d.ts +1 -1
  112. package/dist/components/ui/attachment.d.ts +1 -1
  113. package/dist/components/ui/badge.d.ts +1 -1
  114. package/dist/components/ui/bubble.d.ts +1 -1
  115. package/dist/components/ui/button-group.d.ts +1 -1
  116. package/dist/components/ui/button.d.ts +2 -2
  117. package/dist/components/ui/field.d.ts +1 -1
  118. package/dist/components/ui/item.d.ts +1 -1
  119. package/dist/components/ui/marker.d.ts +1 -1
  120. package/dist/components/ui/tabs.d.ts +1 -1
  121. package/dist/{copy-menu-Bk5GP9Gp.js → copy-menu-1FKoMc9o.js} +9 -2
  122. package/dist/copy-menu-1FKoMc9o.js.map +1 -0
  123. package/dist/hooks/use-dismiss.d.ts +34 -0
  124. package/dist/hooks/use-dismiss.d.ts.map +1 -0
  125. package/dist/hooks/use-dismiss.js +78 -0
  126. package/dist/hooks/use-dismiss.js.map +1 -0
  127. package/dist/hooks/use-favicon.d.ts +17 -0
  128. package/dist/hooks/use-favicon.d.ts.map +1 -0
  129. package/dist/hooks/use-favicon.js +35 -0
  130. package/dist/hooks/use-favicon.js.map +1 -0
  131. package/dist/hooks/use-hover-gesture.d.ts +38 -0
  132. package/dist/hooks/use-hover-gesture.d.ts.map +1 -0
  133. package/dist/hooks/use-hover-gesture.js +46 -0
  134. package/dist/hooks/use-hover-gesture.js.map +1 -0
  135. package/dist/hooks/use-slider.d.ts.map +1 -1
  136. package/dist/hooks/use-slider.js +3 -2
  137. package/dist/hooks/use-slider.js.map +1 -1
  138. package/dist/hooks/use-tap-gesture.d.ts +47 -0
  139. package/dist/hooks/use-tap-gesture.d.ts.map +1 -0
  140. package/dist/hooks/use-tap-gesture.js +51 -0
  141. package/dist/hooks/use-tap-gesture.js.map +1 -0
  142. package/dist/hooks/use-touch-capable.d.ts +15 -0
  143. package/dist/hooks/use-touch-capable.d.ts.map +1 -0
  144. package/dist/hooks/use-touch-capable.js +29 -0
  145. package/dist/hooks/use-touch-capable.js.map +1 -0
  146. package/dist/lib/touch.d.ts +66 -0
  147. package/dist/lib/touch.d.ts.map +1 -0
  148. package/dist/lib/touch.js +79 -0
  149. package/dist/lib/touch.js.map +1 -0
  150. package/dist/types-smkWN_7x.d.ts.map +1 -1
  151. package/package.json +1 -1
  152. package/dist/copy-menu-Bk5GP9Gp.js.map +0 -1
@@ -11,7 +11,7 @@ declare const itemVariants: (props?: ({
11
11
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
12
12
  declare function Item({ className, variant, size, render, ...props }: useRender.ComponentProps<"div"> & VariantProps<typeof itemVariants>): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
13
13
  declare const itemMediaVariants: (props?: ({
14
- variant?: "image" | "default" | "icon" | null | undefined;
14
+ variant?: "default" | "image" | "icon" | null | undefined;
15
15
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
16
16
  declare function ItemMedia({ className, variant, ...props }: React$1.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>): React$1.JSX.Element;
17
17
  declare function ItemContent({ className, ...props }: React$1.ComponentProps<"div">): React$1.JSX.Element;
@@ -3,7 +3,7 @@ import { VariantProps } from "class-variance-authority";
3
3
  import { useRender } from "@base-ui/react/use-render";
4
4
  //#region src/components/ui/marker.d.ts
5
5
  declare const markerVariants: (props?: ({
6
- variant?: "separator" | "default" | "border" | null | undefined;
6
+ variant?: "default" | "separator" | "border" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  declare function Marker({ className, variant, render, ...props }: useRender.ComponentProps<"div"> & VariantProps<typeof markerVariants>): React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>>;
9
9
  declare function MarkerIcon({ className, ...props }: React$1.ComponentProps<"span">): React$1.JSX.Element;
@@ -3,7 +3,7 @@ import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
3
3
  //#region src/components/ui/tabs.d.ts
4
4
  declare function Tabs({ className, orientation, ...props }: Tabs$1.Root.Props): import("react").JSX.Element;
5
5
  declare const tabsListVariants: (props?: ({
6
- variant?: "line" | "default" | null | undefined;
6
+ variant?: "default" | "line" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  declare function TabsList({ className, variant, ...props }: Tabs$1.List.Props & VariantProps<typeof tabsListVariants>): import("react").JSX.Element;
9
9
  declare function TabsTrigger({ className, ...props }: Tabs$1.Tab.Props): import("react").JSX.Element;
@@ -38,6 +38,13 @@ const WEEKDAYS = [
38
38
  label: "Sunday"
39
39
  }
40
40
  ];
41
+ /**
42
+ * Names one time field week-wide, because the scheduler holds a single open
43
+ * panel for the whole week. Range ids belong to the value and are only unique
44
+ * within a day, so the day is part of the name — and the scheduler builds the
45
+ * same keys to ask whether the panel it is holding is still on screen.
46
+ */
47
+ const panelKey = (day, rangeId, edge) => `${day}:${rangeId}:${edge}`;
41
48
  const toMinutes = (v) => {
42
49
  const [h, m] = v.split(":").map(Number);
43
50
  return h * 60 + m;
@@ -196,6 +203,6 @@ function CopyMenu({ fromLabel, reduce, onApply }) {
196
203
  });
197
204
  }
198
205
  //#endregion
199
- export { toMinutes as a, defaultWeek as i, WEEKDAYS as n, toValue as o, buildOptions as r, CopyMenu as t };
206
+ export { panelKey as a, defaultWeek as i, WEEKDAYS as n, toMinutes as o, buildOptions as r, toValue as s, CopyMenu as t };
200
207
 
201
- //# sourceMappingURL=copy-menu-Bk5GP9Gp.js.map
208
+ //# sourceMappingURL=copy-menu-1FKoMc9o.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy-menu-1FKoMc9o.js","names":[],"sources":["../src/components/motion/availability-scheduler/types.ts","../src/components/motion/availability-scheduler/copy-menu.tsx"],"sourcesContent":["export type DayKey = \"mon\" | \"tue\" | \"wed\" | \"thu\" | \"fri\" | \"sat\" | \"sun\";\n\nexport type TimeRange = { id: string; start: string; end: string };\nexport type DayAvailability = { enabled: boolean; ranges: TimeRange[] };\nexport type WeekAvailability = Record<DayKey, DayAvailability>;\nexport type TimeOption = { value: string; label: string };\n\nexport const WEEKDAYS: { key: DayKey; label: string }[] = [\n { key: \"mon\", label: \"Monday\" },\n { key: \"tue\", label: \"Tuesday\" },\n { key: \"wed\", label: \"Wednesday\" },\n { key: \"thu\", label: \"Thursday\" },\n { key: \"fri\", label: \"Friday\" },\n { key: \"sat\", label: \"Saturday\" },\n { key: \"sun\", label: \"Sunday\" },\n];\n\n// ─── panels ──────────────────────────────────────────────────────────────────\n\n/**\n * Names one time field week-wide, because the scheduler holds a single open\n * panel for the whole week. Range ids belong to the value and are only unique\n * within a day, so the day is part of the name — and the scheduler builds the\n * same keys to ask whether the panel it is holding is still on screen.\n */\nexport const panelKey = (day: DayKey, rangeId: string, edge: \"start\" | \"end\") =>\n `${day}:${rangeId}:${edge}`;\n\n// ─── time helpers ────────────────────────────────────────────────────────────\n\nexport const toMinutes = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n return h * 60 + m;\n};\n\nexport const toValue = (mins: number) => {\n const clamped = Math.max(0, Math.min(24 * 60 - 1, mins));\n const h = Math.floor(clamped / 60);\n const m = clamped % 60;\n return `${String(h).padStart(2, \"0\")}:${String(m).padStart(2, \"0\")}`;\n};\n\nexport const label12 = (v: string) => {\n const [h, m] = v.split(\":\").map(Number);\n const ap = h < 12 ? \"AM\" : \"PM\";\n const h12 = h % 12 === 0 ? 12 : h % 12;\n return `${h12}:${String(m).padStart(2, \"0\")} ${ap}`;\n};\n\nexport function buildOptions(step: number): TimeOption[] {\n const out: TimeOption[] = [];\n for (let m = 0; m < 24 * 60; m += step) {\n const value = toValue(m);\n out.push({ value, label: label12(value) });\n }\n return out;\n}\n\n// Default: Mon–Fri 9–5, weekend off. Fixed ids so SSR and first client render\n// agree (new ranges get counter ids afterwards).\nexport function defaultWeek(): WeekAvailability {\n const workday = (day: DayKey): DayAvailability => ({\n enabled: true,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n const off = (day: DayKey): DayAvailability => ({\n enabled: false,\n ranges: [{ id: `${day}-0`, start: \"09:00\", end: \"17:00\" }],\n });\n return {\n mon: workday(\"mon\"),\n tue: workday(\"tue\"),\n wed: workday(\"wed\"),\n thu: workday(\"thu\"),\n fri: workday(\"fri\"),\n sat: off(\"sat\"),\n sun: off(\"sun\"),\n };\n}\n","\"use client\";\n\nimport { useState } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport { AnimatePresence, motion } from \"motion/react\";\n\nimport { SPRING_PRESS } from \"../../../lib/ease\";\nimport { Checkbox } from \"../checkbox\";\nimport { MorphPopover, MorphPopoverContent } from \"../popover-morph\";\nimport { Tooltip } from \"../tooltip\";\nimport { IconButton } from \"./icon-button\";\nimport { type DayKey, WEEKDAYS } from \"./types\";\n\n// Copy this day's hours to other days: a morph popover with a day picker.\nexport function CopyMenu({\n fromLabel,\n reduce,\n onApply,\n}: {\n fromLabel: string;\n reduce: boolean;\n onApply: (targets: DayKey[]) => void;\n}) {\n const [open, setOpen] = useState(false);\n const [copied, setCopied] = useState(false);\n const [picked, setPicked] = useState<Set<DayKey>>(new Set());\n const others = WEEKDAYS.filter((d) => d.label !== fromLabel);\n\n const toggle = (k: DayKey) =>\n setPicked((prev) => {\n const next = new Set(prev);\n if (next.has(k)) next.delete(k);\n else next.add(k);\n return next;\n });\n\n const apply = (targets: DayKey[]) => {\n if (!targets.length) return;\n onApply(targets);\n setOpen(false);\n setPicked(new Set());\n setCopied(true);\n window.setTimeout(() => setCopied(false), 1200);\n };\n\n return (\n <MorphPopover open={open} onOpenChange={setOpen}>\n <Tooltip content=\"Copy times\">\n <IconButton\n label={`Copy ${fromLabel} hours to other days`}\n reduce={reduce}\n expanded={open}\n onClick={() => setOpen(!open)}\n >\n <AnimatePresence mode=\"popLayout\" initial={false}>\n {copied ? (\n <motion.span\n key=\"done\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n className=\"text-foreground\"\n >\n <Check className=\"h-4 w-4\" />\n </motion.span>\n ) : (\n <motion.span\n key=\"copy\"\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}\n transition={SPRING_PRESS}\n >\n <Copy className=\"h-4 w-4\" />\n </motion.span>\n )}\n </AnimatePresence>\n </IconButton>\n </Tooltip>\n\n <MorphPopoverContent align=\"end\" className=\"w-52 p-2\">\n <p className=\"px-2 py-1.5 font-medium text-muted-foreground text-xs\">Copy times to</p>\n <div className=\"flex flex-col\">\n {others.map((d) => (\n <Checkbox\n key={d.key}\n checked={picked.has(d.key)}\n onCheckedChange={() => toggle(d.key)}\n label={d.label}\n className=\"w-full flex-row-reverse justify-between rounded-lg px-2 py-1.5 transition-colors hover:bg-muted [&_button[data-state=unchecked]]:border-border-strong [&_button]:size-4 [&_button]:rounded-[5px] [&_button]:border\"\n />\n ))}\n </div>\n <div className=\"mt-1 flex items-center gap-2 border-border border-t px-1 pt-2\">\n <button\n type=\"button\"\n onClick={() => apply(others.map((d) => d.key))}\n className=\"flex-1 rounded-lg px-2 py-1.5 font-medium text-muted-foreground text-xs outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:bg-muted\"\n >\n Every day\n </button>\n <button\n type=\"button\"\n onClick={() => apply([...picked])}\n disabled={picked.size === 0}\n className=\"flex-1 rounded-lg bg-primary px-2 py-1.5 font-semibold text-primary-foreground text-xs outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-40\"\n >\n Apply\n </button>\n </div>\n </MorphPopoverContent>\n </MorphPopover>\n );\n}\n"],"mappings":";;;;;;;;;;AAOA,MAAa,WAA6C;CACxD;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAU;CAC/B;EAAE,KAAK;EAAO,OAAO;CAAY;CACjC;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;CAC9B;EAAE,KAAK;EAAO,OAAO;CAAW;CAChC;EAAE,KAAK;EAAO,OAAO;CAAS;AAChC;;;;;;;AAUA,MAAa,YAAY,KAAa,SAAiB,SACrD,GAAG,IAAI,GAAG,QAAQ,GAAG;AAIvB,MAAa,aAAa,MAAc;CACtC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtC,OAAO,IAAI,KAAK;AAClB;AAEA,MAAa,WAAW,SAAiB;CACvC,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,MAAa,IAAI,CAAC;CACvD,MAAM,IAAI,KAAK,MAAM,UAAU,EAAE;CACjC,MAAM,IAAI,UAAU;CACpB,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;AACnE;AAEA,MAAa,WAAW,MAAc;CACpC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CACtC,MAAM,KAAK,IAAI,KAAK,OAAO;CAE3B,OAAO,GADK,IAAI,OAAO,IAAI,KAAK,IAAI,GACtB,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG;AACjD;AAEA,SAAgB,aAAa,MAA4B;CACvD,MAAM,MAAoB,CAAC;CAC3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AU;KAAf,UAAA,CACE,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,OAAO,KAAK,MAAM,EAAE,GAAG,CAAC;MAC7C,WAAU;MACX,UAAA;KAEO,CAAA,GACR,oBAAC,UAAD;MACE,MAAK;MACL,eAAe,MAAM,CAAC,GAAG,MAAM,CAAC;MAChC,UAAU,OAAO,SAAS;MAC1B,WAAU;MACX,UAAA;KAEO,CAAA,CACL;;GACc;EACT,CAAA,CAAA;;AAElB"}
@@ -0,0 +1,34 @@
1
+ import { RefObject } from "react";
2
+ //#region src/hooks/use-dismiss.d.ts
3
+ /**
4
+ * What the dismissing gesture does to the control it landed on.
5
+ *
6
+ * `"pass-through"` is the platform norm (native popover light-dismiss): the
7
+ * tap closes the overlay *and* activates whatever was under it. Use
8
+ * `"consume"` where the open overlay sits over or beside controls that would
9
+ * be costly to trigger by accident — the dismissal then swallows the
10
+ * activation too, so the gesture only closes.
11
+ */
12
+ type DismissBehavior = "pass-through" | "consume";
13
+ interface DismissOptions {
14
+ /** Default `"pass-through"`. */
15
+ behavior?: DismissBehavior;
16
+ /** Dismiss on Escape as well. Default true. */
17
+ escape?: boolean;
18
+ /** Return true for an outside target that should *not* dismiss. Must be stable. */
19
+ ignore?: (target: Element) => boolean;
20
+ }
21
+ /**
22
+ * Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`
23
+ * for `ref` when what counts as inside isn't one element, and say so with
24
+ * `ignore` instead.
25
+ *
26
+ * The pointerdown listener is capture-phase: a bubble-phase one is blinded by
27
+ * any handler in between that stops propagation, and an overlay cannot know
28
+ * what it is layered over. `onDismiss` and `ignore` must be stable (wrap in
29
+ * useCallback) so the listeners aren't re-bound every render while open.
30
+ */
31
+ declare function useDismiss(open: boolean, onDismiss: () => void, ref: RefObject<HTMLElement | null> | null, { behavior, escape: dismissOnEscape, ignore }?: DismissOptions): void;
32
+ //#endregion
33
+ export { DismissBehavior, DismissOptions, useDismiss };
34
+ //# sourceMappingURL=use-dismiss.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-dismiss.d.ts","names":[],"sources":["../../src/hooks/use-dismiss.ts"],"mappings":";;;;;;;;;;;KAaY;UAEK;;EAEf,WAAW;;EAEX;;EAEA,UAAU,QAAQ;;;;;;;;;;;;iBA0DJ,WACd,eACA,uBACA,KAAK,UAAU,8BACb,UAA2B,QAAQ,iBAAwB,WAAU"}
@@ -0,0 +1,78 @@
1
+ "use client";
2
+ import { useEffect } from "react";
3
+ //#region src/hooks/use-dismiss.ts
4
+ /**
5
+ * What every currently open dismiss scope counts as inside itself. A consumed
6
+ * dismissal reads this to tell a stray gesture from one that belongs to an
7
+ * overlay in front of it: overlays have no shared z-order to consult, but the
8
+ * one the gesture landed in has said as much by registering it.
9
+ */
10
+ const openScopes = /* @__PURE__ */ new Set();
11
+ function claimedByAnotherScope(self, target) {
12
+ for (const scope of openScopes) if (scope !== self && scope(target)) return true;
13
+ return false;
14
+ }
15
+ function consumeActivation(source) {
16
+ const swallow = (event) => {
17
+ event.preventDefault();
18
+ event.stopPropagation();
19
+ release();
20
+ };
21
+ const restart = (event) => {
22
+ if (event !== source) release();
23
+ };
24
+ const release = () => {
25
+ window.removeEventListener("click", swallow, true);
26
+ window.removeEventListener("pointerdown", restart, true);
27
+ window.removeEventListener("pointercancel", restart, true);
28
+ window.removeEventListener("keydown", release, true);
29
+ };
30
+ window.addEventListener("click", swallow, true);
31
+ window.addEventListener("pointerdown", restart, true);
32
+ window.addEventListener("pointercancel", restart, true);
33
+ window.addEventListener("keydown", release, true);
34
+ }
35
+ /**
36
+ * Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`
37
+ * for `ref` when what counts as inside isn't one element, and say so with
38
+ * `ignore` instead.
39
+ *
40
+ * The pointerdown listener is capture-phase: a bubble-phase one is blinded by
41
+ * any handler in between that stops propagation, and an overlay cannot know
42
+ * what it is layered over. `onDismiss` and `ignore` must be stable (wrap in
43
+ * useCallback) so the listeners aren't re-bound every render while open.
44
+ */
45
+ function useDismiss(open, onDismiss, ref, { behavior = "pass-through", escape: dismissOnEscape = true, ignore } = {}) {
46
+ useEffect(() => {
47
+ if (!open) return;
48
+ const inside = (target) => Boolean(ref?.current?.contains(target)) || Boolean(ignore?.(target));
49
+ const onKey = (event) => {
50
+ if (dismissOnEscape && event.key === "Escape") onDismiss();
51
+ };
52
+ const onPointer = (event) => {
53
+ const target = event.target;
54
+ if (!target || inside(target)) return;
55
+ if (behavior === "consume" && !claimedByAnotherScope(inside, target)) consumeActivation(event);
56
+ onDismiss();
57
+ };
58
+ openScopes.add(inside);
59
+ window.addEventListener("keydown", onKey);
60
+ window.addEventListener("pointerdown", onPointer, true);
61
+ return () => {
62
+ openScopes.delete(inside);
63
+ window.removeEventListener("keydown", onKey);
64
+ window.removeEventListener("pointerdown", onPointer, true);
65
+ };
66
+ }, [
67
+ open,
68
+ onDismiss,
69
+ ref,
70
+ behavior,
71
+ dismissOnEscape,
72
+ ignore
73
+ ]);
74
+ }
75
+ //#endregion
76
+ export { useDismiss };
77
+
78
+ //# sourceMappingURL=use-dismiss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-dismiss.js","names":[],"sources":["../../src/hooks/use-dismiss.ts"],"sourcesContent":["\"use client\";\n\nimport { type RefObject, useEffect } from \"react\";\n\n/**\n * What the dismissing gesture does to the control it landed on.\n *\n * `\"pass-through\"` is the platform norm (native popover light-dismiss): the\n * tap closes the overlay *and* activates whatever was under it. Use\n * `\"consume\"` where the open overlay sits over or beside controls that would\n * be costly to trigger by accident — the dismissal then swallows the\n * activation too, so the gesture only closes.\n */\nexport type DismissBehavior = \"pass-through\" | \"consume\";\n\nexport interface DismissOptions {\n /** Default `\"pass-through\"`. */\n behavior?: DismissBehavior;\n /** Dismiss on Escape as well. Default true. */\n escape?: boolean;\n /** Return true for an outside target that should *not* dismiss. Must be stable. */\n ignore?: (target: Element) => boolean;\n}\n\n/**\n * What every currently open dismiss scope counts as inside itself. A consumed\n * dismissal reads this to tell a stray gesture from one that belongs to an\n * overlay in front of it: overlays have no shared z-order to consult, but the\n * one the gesture landed in has said as much by registering it.\n */\nconst openScopes = new Set<(target: Element) => boolean>();\n\nfunction claimedByAnotherScope(self: (target: Element) => boolean, target: Element) {\n for (const scope of openScopes) {\n if (scope !== self && scope(target)) return true;\n }\n return false;\n}\n\n// preventDefault on pointerdown does not suppress the click that follows, so\n// consuming a gesture means swallowing that click itself. The swallower\n// deliberately outlives the effect that installed it — the dismissal it\n// belongs to has already unmounted or re-rendered by the time the click lands.\n// It releases on that click, or on the next gesture if the pointer is dragged\n// away and no click ever arrives, so it can never eat a later one. A keydown\n// releases it too: a gesture that ends with neither a click nor a cancel would\n// otherwise leave it armed, and the click Enter synthesizes on some focused\n// control is not the one this dismissal was owed.\nfunction consumeActivation(source: Event) {\n const swallow = (event: MouseEvent) => {\n event.preventDefault();\n event.stopPropagation();\n release();\n };\n const restart = (event: Event) => {\n if (event !== source) release();\n };\n const release = () => {\n window.removeEventListener(\"click\", swallow, true);\n window.removeEventListener(\"pointerdown\", restart, true);\n window.removeEventListener(\"pointercancel\", restart, true);\n window.removeEventListener(\"keydown\", release, true);\n };\n window.addEventListener(\"click\", swallow, true);\n window.addEventListener(\"pointerdown\", restart, true);\n window.addEventListener(\"pointercancel\", restart, true);\n window.addEventListener(\"keydown\", release, true);\n}\n\n/**\n * Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`\n * for `ref` when what counts as inside isn't one element, and say so with\n * `ignore` instead.\n *\n * The pointerdown listener is capture-phase: a bubble-phase one is blinded by\n * any handler in between that stops propagation, and an overlay cannot know\n * what it is layered over. `onDismiss` and `ignore` must be stable (wrap in\n * useCallback) so the listeners aren't re-bound every render while open.\n */\nexport function useDismiss(\n open: boolean,\n onDismiss: () => void,\n ref: RefObject<HTMLElement | null> | null,\n { behavior = \"pass-through\", escape: dismissOnEscape = true, ignore }: DismissOptions = {},\n) {\n useEffect(() => {\n if (!open) return;\n const inside = (target: Element) =>\n Boolean(ref?.current?.contains(target)) || Boolean(ignore?.(target));\n const onKey = (event: KeyboardEvent) => {\n if (dismissOnEscape && event.key === \"Escape\") onDismiss();\n };\n const onPointer = (event: PointerEvent) => {\n const target = event.target as Element | null;\n if (!target || inside(target)) return;\n // Outside this overlay, but inside one that is also open: the gesture is\n // that overlay's to answer, and swallowing its click from behind would\n // cost the user the control they actually aimed at.\n if (behavior === \"consume\" && !claimedByAnotherScope(inside, target)) {\n consumeActivation(event);\n }\n onDismiss();\n };\n openScopes.add(inside);\n window.addEventListener(\"keydown\", onKey);\n window.addEventListener(\"pointerdown\", onPointer, true);\n return () => {\n openScopes.delete(inside);\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer, true);\n };\n }, [open, onDismiss, ref, behavior, dismissOnEscape, ignore]);\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,6BAAa,IAAI,IAAkC;AAEzD,SAAS,sBAAsB,MAAoC,QAAiB;CAClF,KAAK,MAAM,SAAS,YAClB,IAAI,UAAU,QAAQ,MAAM,MAAM,GAAG,OAAO;CAE9C,OAAO;AACT;AAWA,SAAS,kBAAkB,QAAe;CACxC,MAAM,WAAW,UAAsB;EACrC,MAAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,QAAQ;CACV;CACA,MAAM,WAAW,UAAiB;EAChC,IAAI,UAAU,QAAQ,QAAQ;CAChC;CACA,MAAM,gBAAgB;EACpB,OAAO,oBAAoB,SAAS,SAAS,IAAI;EACjD,OAAO,oBAAoB,eAAe,SAAS,IAAI;EACvD,OAAO,oBAAoB,iBAAiB,SAAS,IAAI;EACzD,OAAO,oBAAoB,WAAW,SAAS,IAAI;CACrD;CACA,OAAO,iBAAiB,SAAS,SAAS,IAAI;CAC9C,OAAO,iBAAiB,eAAe,SAAS,IAAI;CACpD,OAAO,iBAAiB,iBAAiB,SAAS,IAAI;CACtD,OAAO,iBAAiB,WAAW,SAAS,IAAI;AAClD;;;;;;;;;;;AAYA,SAAgB,WACd,MACA,WACA,KACA,EAAE,WAAW,gBAAgB,QAAQ,kBAAkB,MAAM,WAA2B,CAAC,GACzF;CACA,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,UAAU,WACd,QAAQ,KAAK,SAAS,SAAS,MAAM,CAAC,KAAK,QAAQ,SAAS,MAAM,CAAC;EACrE,MAAM,SAAS,UAAyB;GACtC,IAAI,mBAAmB,MAAM,QAAQ,UAAU,UAAU;EAC3D;EACA,MAAM,aAAa,UAAwB;GACzC,MAAM,SAAS,MAAM;GACrB,IAAI,CAAC,UAAU,OAAO,MAAM,GAAG;GAI/B,IAAI,aAAa,aAAa,CAAC,sBAAsB,QAAQ,MAAM,GACjE,kBAAkB,KAAK;GAEzB,UAAU;EACZ;EACA,WAAW,IAAI,MAAM;EACrB,OAAO,iBAAiB,WAAW,KAAK;EACxC,OAAO,iBAAiB,eAAe,WAAW,IAAI;EACtD,aAAa;GACX,WAAW,OAAO,MAAM;GACxB,OAAO,oBAAoB,WAAW,KAAK;GAC3C,OAAO,oBAAoB,eAAe,WAAW,IAAI;EAC3D;CACF,GAAG;EAAC;EAAM;EAAW;EAAK;EAAU;EAAiB;CAAM,CAAC;AAC9D"}
@@ -0,0 +1,17 @@
1
+ //#region src/hooks/use-favicon.d.ts
2
+ /**
3
+ * Resolves a site favicon and drops it once it is known to be unusable, so
4
+ * callers can draw their own glyph instead of a broken image. Plenty of sites
5
+ * answer `/favicon.ico` with a 403 or 404, and `onError` is not enough to catch
6
+ * it: an image the browser starts loading from server-rendered HTML usually
7
+ * fails before React attaches a handler, and that event is never replayed.
8
+ * `decode()` settles on the image's final state instead of relying on an event
9
+ * firing at the right moment.
10
+ */
11
+ declare function useFavicon(url?: string): {
12
+ src: string | null;
13
+ ref: (img: HTMLImageElement | null) => (() => void) | undefined;
14
+ };
15
+ //#endregion
16
+ export { useFavicon };
17
+ //# sourceMappingURL=use-favicon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-favicon.d.ts","names":[],"sources":["../../src/hooks/use-favicon.ts"],"mappings":";;;;;;;;;;iBAegB,WAAW;;EAMjB,MAAA,KAAA"}
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { getFaviconUrl } from "../lib/favicon.js";
3
+ import { useCallback, useState } from "react";
4
+ //#region src/hooks/use-favicon.ts
5
+ /**
6
+ * Resolves a site favicon and drops it once it is known to be unusable, so
7
+ * callers can draw their own glyph instead of a broken image. Plenty of sites
8
+ * answer `/favicon.ico` with a 403 or 404, and `onError` is not enough to catch
9
+ * it: an image the browser starts loading from server-rendered HTML usually
10
+ * fails before React attaches a handler, and that event is never replayed.
11
+ * `decode()` settles on the image's final state instead of relying on an event
12
+ * firing at the right moment.
13
+ */
14
+ function useFavicon(url) {
15
+ const resolved = url ? getFaviconUrl(url) : null;
16
+ const [failedSrc, setFailedSrc] = useState(null);
17
+ const src = resolved && resolved !== failedSrc ? resolved : null;
18
+ return {
19
+ src,
20
+ ref: useCallback((img) => {
21
+ if (!img || !src) return;
22
+ let released = false;
23
+ img.decode().catch(() => {
24
+ if (!released) setFailedSrc(src);
25
+ });
26
+ return () => {
27
+ released = true;
28
+ };
29
+ }, [src])
30
+ };
31
+ }
32
+ //#endregion
33
+ export { useFavicon };
34
+
35
+ //# sourceMappingURL=use-favicon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-favicon.js","names":[],"sources":["../../src/hooks/use-favicon.ts"],"sourcesContent":["\"use client\";\n\nimport { useCallback, useState } from \"react\";\n\nimport { getFaviconUrl } from \"../lib/favicon\";\n\n/**\n * Resolves a site favicon and drops it once it is known to be unusable, so\n * callers can draw their own glyph instead of a broken image. Plenty of sites\n * answer `/favicon.ico` with a 403 or 404, and `onError` is not enough to catch\n * it: an image the browser starts loading from server-rendered HTML usually\n * fails before React attaches a handler, and that event is never replayed.\n * `decode()` settles on the image's final state instead of relying on an event\n * firing at the right moment.\n */\nexport function useFavicon(url?: string) {\n const resolved = url ? getFaviconUrl(url) : null;\n const [failedSrc, setFailedSrc] = useState<string | null>(null);\n const src = resolved && resolved !== failedSrc ? resolved : null;\n\n const ref = useCallback(\n (img: HTMLImageElement | null) => {\n if (!img || !src) return;\n\n let released = false;\n img.decode().catch(() => {\n if (!released) setFailedSrc(src);\n });\n\n // The node is going away or the source changed; a late rejection then\n // describes an image we are no longer showing.\n return () => {\n released = true;\n };\n },\n [src],\n );\n\n return { src, ref };\n}\n"],"mappings":";;;;;;;;;;;;;AAeA,SAAgB,WAAW,KAAc;CACvC,MAAM,WAAW,MAAM,cAAc,GAAG,IAAI;CAC5C,MAAM,CAAC,WAAW,gBAAgB,SAAwB,IAAI;CAC9D,MAAM,MAAM,YAAY,aAAa,YAAY,WAAW;CAoB5D,OAAO;EAAE;EAAK,KAlBF,aACT,QAAiC;GAChC,IAAI,CAAC,OAAO,CAAC,KAAK;GAElB,IAAI,WAAW;GACf,IAAI,OAAO,CAAC,CAAC,YAAY;IACvB,IAAI,CAAC,UAAU,aAAa,GAAG;GACjC,CAAC;GAID,aAAa;IACX,WAAW;GACb;EACF,GACA,CAAC,GAAG,CAGU;CAAE;AACpB"}
@@ -0,0 +1,38 @@
1
+ //#region src/hooks/use-hover-gesture.d.ts
2
+ interface BoundaryEvent {
3
+ pointerId: number;
4
+ pointerType: string;
5
+ buttons: number;
6
+ }
7
+ interface HoverGesture {
8
+ /** True when this enter starts a hover: the pointer arrived resting, not pressing. */
9
+ enter: (event: BoundaryEvent) => boolean;
10
+ /** True when this leave ends a hover that entered as one. */
11
+ leave: (event: BoundaryEvent) => boolean;
12
+ }
13
+ /**
14
+ * Pairs a surface's enter with its leave, per pointer.
15
+ *
16
+ * `isHoveringPointer` answers the question the *enter* asks — is this pointer
17
+ * resting on the surface or pressing it — and both boundary cases go wrong if
18
+ * the leave is asked the same question again:
19
+ *
20
+ * - A pen with no hover never rests. It arrives in contact, taps, and the spec
21
+ * then requires its boundary events after `pointerup`, so the leave carries
22
+ * `buttons: 0` and reads as a mouse gliding off. Hover teardown then undid
23
+ * the tap — the panel the pen had just opened closed under it.
24
+ * - A mouse pressed on the surface and dragged off leaves with `buttons: 1`.
25
+ * Skipping teardown there strands the surface open: the release happens
26
+ * outside, and no second leave ever comes.
27
+ *
28
+ * So the state a hover holds is released by the pointer that took it, whatever
29
+ * the buttons say at the boundary, and a pointer that arrived in contact never
30
+ * took it in the first place. Contact is the exception tracked here, not
31
+ * hover: a leave from a pointer this surface never saw enter — mounted under
32
+ * the cursor, say — still counts, since the alternative is state with no way
33
+ * out.
34
+ */
35
+ declare function useHoverGesture(): HoverGesture;
36
+ //#endregion
37
+ export { HoverGesture, useHoverGesture };
38
+ //# sourceMappingURL=use-hover-gesture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-hover-gesture.d.ts","names":[],"sources":["../../src/hooks/use-hover-gesture.ts"],"mappings":";UAMU;EACR;EACA;EACA;;UAGe;;EAEf,QAAQ,OAAO;;EAEf,QAAQ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;iBAyBD,mBAAmB"}
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { isHoveringPointer } from "../lib/touch.js";
3
+ import { useMemo, useRef } from "react";
4
+ //#region src/hooks/use-hover-gesture.ts
5
+ /**
6
+ * Pairs a surface's enter with its leave, per pointer.
7
+ *
8
+ * `isHoveringPointer` answers the question the *enter* asks — is this pointer
9
+ * resting on the surface or pressing it — and both boundary cases go wrong if
10
+ * the leave is asked the same question again:
11
+ *
12
+ * - A pen with no hover never rests. It arrives in contact, taps, and the spec
13
+ * then requires its boundary events after `pointerup`, so the leave carries
14
+ * `buttons: 0` and reads as a mouse gliding off. Hover teardown then undid
15
+ * the tap — the panel the pen had just opened closed under it.
16
+ * - A mouse pressed on the surface and dragged off leaves with `buttons: 1`.
17
+ * Skipping teardown there strands the surface open: the release happens
18
+ * outside, and no second leave ever comes.
19
+ *
20
+ * So the state a hover holds is released by the pointer that took it, whatever
21
+ * the buttons say at the boundary, and a pointer that arrived in contact never
22
+ * took it in the first place. Contact is the exception tracked here, not
23
+ * hover: a leave from a pointer this surface never saw enter — mounted under
24
+ * the cursor, say — still counts, since the alternative is state with no way
25
+ * out.
26
+ */
27
+ function useHoverGesture() {
28
+ const contact = useRef(/* @__PURE__ */ new Set());
29
+ return useMemo(() => ({
30
+ enter: (event) => {
31
+ if (isHoveringPointer(event)) {
32
+ contact.current.delete(event.pointerId);
33
+ return true;
34
+ }
35
+ contact.current.add(event.pointerId);
36
+ return false;
37
+ },
38
+ leave: (event) => {
39
+ return !contact.current.delete(event.pointerId) && event.pointerType !== "touch";
40
+ }
41
+ }), []);
42
+ }
43
+ //#endregion
44
+ export { useHoverGesture };
45
+
46
+ //# sourceMappingURL=use-hover-gesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-hover-gesture.js","names":[],"sources":["../../src/hooks/use-hover-gesture.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo, useRef } from \"react\";\n\nimport { isHoveringPointer } from \"../lib/touch\";\n\ninterface BoundaryEvent {\n pointerId: number;\n pointerType: string;\n buttons: number;\n}\n\nexport interface HoverGesture {\n /** True when this enter starts a hover: the pointer arrived resting, not pressing. */\n enter: (event: BoundaryEvent) => boolean;\n /** True when this leave ends a hover that entered as one. */\n leave: (event: BoundaryEvent) => boolean;\n}\n\n/**\n * Pairs a surface's enter with its leave, per pointer.\n *\n * `isHoveringPointer` answers the question the *enter* asks — is this pointer\n * resting on the surface or pressing it — and both boundary cases go wrong if\n * the leave is asked the same question again:\n *\n * - A pen with no hover never rests. It arrives in contact, taps, and the spec\n * then requires its boundary events after `pointerup`, so the leave carries\n * `buttons: 0` and reads as a mouse gliding off. Hover teardown then undid\n * the tap — the panel the pen had just opened closed under it.\n * - A mouse pressed on the surface and dragged off leaves with `buttons: 1`.\n * Skipping teardown there strands the surface open: the release happens\n * outside, and no second leave ever comes.\n *\n * So the state a hover holds is released by the pointer that took it, whatever\n * the buttons say at the boundary, and a pointer that arrived in contact never\n * took it in the first place. Contact is the exception tracked here, not\n * hover: a leave from a pointer this surface never saw enter — mounted under\n * the cursor, say — still counts, since the alternative is state with no way\n * out.\n */\nexport function useHoverGesture(): HoverGesture {\n const contact = useRef(new Set<number>());\n\n return useMemo(\n () => ({\n enter: (event) => {\n if (isHoveringPointer(event)) {\n contact.current.delete(event.pointerId);\n return true;\n }\n contact.current.add(event.pointerId);\n return false;\n },\n leave: (event) => {\n const arrivedInContact = contact.current.delete(event.pointerId);\n return !arrivedInContact && event.pointerType !== \"touch\";\n },\n }),\n [],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,SAAgB,kBAAgC;CAC9C,MAAM,UAAU,uBAAO,IAAI,IAAY,CAAC;CAExC,OAAO,eACE;EACL,QAAQ,UAAU;GAChB,IAAI,kBAAkB,KAAK,GAAG;IAC5B,QAAQ,QAAQ,OAAO,MAAM,SAAS;IACtC,OAAO;GACT;GACA,QAAQ,QAAQ,IAAI,MAAM,SAAS;GACnC,OAAO;EACT;EACA,QAAQ,UAAU;GAEhB,OAAO,CADkB,QAAQ,QAAQ,OAAO,MAAM,SAC/B,KAAK,MAAM,gBAAgB;EACpD;CACF,IACA,CAAC,CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-slider.d.ts","names":[],"sources":["../../src/hooks/use-slider.ts"],"mappings":";;;;;iBASgB,gBAAgB,cAAc,aAAa,aAAa;UAavD;EACf;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;;;EAGA,mBAAmB;;;;;;;iBAQL,YACd,OACA,cACA,eACA,KACA,KACA,MACA,wBACc,WACd,mBACC;;;;;;;EAmBQ,SAAA;;;;IAmBC,gBAAA,OAAA,aAAa;IAcb,gBAAA,OAAA,aAAa;IAOa,cAAA,OAAA,aAAa;IAAb,kBAAA,OAAA,aAAa;IAAb,uBAAA,OAAA,aAAa;;;;IAmDjC,MAAA,MAAA;;;;;;;;;IAxCN,YAAA,OAAA,cAAc"}
1
+ {"version":3,"file":"use-slider.d.ts","names":[],"sources":["../../src/hooks/use-slider.ts"],"mappings":";;;;;iBAWgB,gBAAgB,cAAc,aAAa,aAAa;UAavD;EACf;EACA;EACA,iBAAiB;EACjB;EACA;EACA;EACA;EACA;;;EAGA,mBAAmB;;;;;;;iBAQL,YACd,OACA,cACA,eACA,KACA,KACA,MACA,wBACc,WACd,mBACC;;;;;;;EAmBQ,SAAA;;;;IAmBC,gBAAA,OAAA,aAAa;IAgBb,gBAAA,OAAA,aAAa;IAOa,cAAA,OAAA,aAAa;IAAb,kBAAA,OAAA,aAAa;IAAb,uBAAA,OAAA,aAAa;;;;IA+CjC,MAAA,MAAA;;;;;;;;;IAxCN,YAAA,OAAA,cAAc"}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { capturePointer, releasePointer } from "../lib/touch.js";
2
3
  import { useCallback, useRef, useState } from "react";
3
4
  //#region src/hooks/use-slider.ts
4
5
  const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
@@ -54,9 +55,9 @@ function useSlider({ value, defaultValue = 0, onValueChange, min = 0, max = 100,
54
55
  ]);
55
56
  const onPointerDown = useCallback((event) => {
56
57
  if (disabled) return;
57
- event.currentTarget.setPointerCapture?.(event.pointerId);
58
58
  draggingRef.current = true;
59
59
  setDragging(true);
60
+ capturePointer(event.currentTarget, event.pointerId);
60
61
  sliderEl.current?.focus({ preventScroll: true });
61
62
  commitFromX(event.clientX);
62
63
  }, [disabled, commitFromX]);
@@ -65,7 +66,7 @@ function useSlider({ value, defaultValue = 0, onValueChange, min = 0, max = 100,
65
66
  commitFromX(event.clientX);
66
67
  }, [disabled, commitFromX]);
67
68
  const endDrag = useCallback((event) => {
68
- if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);
69
+ releasePointer(event.currentTarget, event.pointerId);
69
70
  draggingRef.current = false;
70
71
  setDragging(false);
71
72
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"use-slider.js","names":[],"sources":["../../src/hooks/use-slider.ts"],"sourcesContent":["\"use client\";\n\nimport { type KeyboardEvent, type PointerEvent, useCallback, useRef, useState } from \"react\";\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n\n/** Nearest legal value on [min, max] for the given step. max counts as a\n * candidate when the step does not divide the range, so a pointer near the end\n * does not snap back onto the last whole step. */\nexport function snapSliderValue(next: number, min: number, max: number, step: number): number {\n // Neither case has a grid to walk. An empty range has exactly one legal\n // point, and a non-positive step only needs a clamp, which also keeps the\n // division below away from zero.\n if (!(max > min)) return min;\n if (!(step > 0)) return clamp(next, min, max);\n const whole = Math.floor(Number(((max - min) / step).toFixed(6)));\n const lastWhole = Number((min + whole * step).toFixed(6));\n const toGrid = clamp(Math.round((next - min) / step) * step + min, min, lastWhole);\n const snapped = lastWhole < max && Math.abs(next - max) <= Math.abs(next - toGrid) ? max : toGrid;\n return Number(snapped.toFixed(6));\n}\n\nexport interface SliderOptions {\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n \"aria-label\"?: string;\n /** Announced instead of the raw number — pass one when the value carries a\n * unit or a suffix (\"72.5 kg\", \"35%\"); a bare number needs no valueText. */\n formatValueText?: (value: number) => string;\n}\n\n/**\n * Shared value + input plumbing for slider designs: controlled/uncontrolled\n * value, step snapping, pointer-capture drag along a track and arrow-key\n * control. Visuals and motion live in the component; this only owns the number.\n */\nexport function useSlider({\n value,\n defaultValue = 0,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n disabled = false,\n \"aria-label\": ariaLabel,\n formatValueText,\n}: SliderOptions) {\n const trackRef = useRef<HTMLDivElement>(null);\n const sliderEl = useRef<HTMLElement | null>(null);\n // The state drives visuals. Move reads this ref instead, so the first\n // pointermove after pointerdown does not have to wait on a re-render.\n const draggingRef = useRef(false);\n const [internal, setInternal] = useState(defaultValue);\n const [dragging, setDragging] = useState(false);\n const controlled = value !== undefined;\n // Collapse inverted or empty ranges and non-positive steps here, so that\n // percent, ticks and the keyboard maths never divide by zero or walk a\n // NaN grid.\n const lo = min;\n const hi = max > min ? max : min;\n const stride = step > 0 ? step : 1;\n const current = clamp(controlled ? value : internal, lo, hi);\n const percent = hi > lo ? ((current - lo) / (hi - lo)) * 100 : 0;\n\n const commit = useCallback(\n (next: number) => {\n const clean = snapSliderValue(next, lo, hi, stride);\n if (!controlled) setInternal(clean);\n onValueChange?.(clean);\n },\n [controlled, onValueChange, lo, hi, stride],\n );\n\n const commitFromX = useCallback(\n (clientX: number) => {\n const rect = trackRef.current?.getBoundingClientRect();\n if (!rect || rect.width === 0) return;\n const ratio = clamp((clientX - rect.left) / rect.width, 0, 1);\n commit(lo + ratio * (hi - lo));\n },\n [commit, lo, hi],\n );\n\n const onPointerDown = useCallback(\n (event: PointerEvent<HTMLDivElement>) => {\n if (disabled) return;\n // optional: test DOMs and older browsers omit pointer capture\n event.currentTarget.setPointerCapture?.(event.pointerId);\n draggingRef.current = true;\n setDragging(true);\n // A click on the track should land keyboard focus on the handle.\n sliderEl.current?.focus({ preventScroll: true });\n commitFromX(event.clientX);\n },\n [disabled, commitFromX],\n );\n\n const onPointerMove = useCallback(\n (event: PointerEvent<HTMLDivElement>) => {\n if (!draggingRef.current || disabled) return;\n commitFromX(event.clientX);\n },\n [disabled, commitFromX],\n );\n\n const endDrag = useCallback((event: PointerEvent<HTMLDivElement>) => {\n // Releasing without capture throws. The other pointer hooks guard it the\n // same way.\n if (event.currentTarget.hasPointerCapture?.(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n draggingRef.current = false;\n setDragging(false);\n }, []);\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (disabled) return;\n const map: Record<string, number> = {\n ArrowRight: current + stride,\n ArrowUp: current + stride,\n ArrowLeft: current - stride,\n ArrowDown: current - stride,\n PageUp: current + stride * 10,\n PageDown: current - stride * 10,\n Home: lo,\n End: hi,\n };\n if (event.key in map) {\n event.preventDefault();\n commit(map[event.key]);\n }\n },\n [disabled, current, stride, lo, hi, commit],\n );\n\n return {\n current,\n percent,\n dragging,\n min: lo,\n max: hi,\n step: stride,\n commit,\n /** Pointer handlers for the track element — drag anywhere on it. */\n trackProps: {\n ref: trackRef,\n onPointerDown,\n onPointerMove,\n onPointerUp: endDrag,\n onPointerCancel: endDrag,\n onLostPointerCapture: endDrag,\n },\n /** ARIA + keyboard props for the focusable slider element. */\n sliderProps: {\n // Callback keeps the handle typed across button/div/motion hosts.\n ref: (node: HTMLElement | null) => {\n sliderEl.current = node;\n },\n role: \"slider\" as const,\n tabIndex: disabled ? -1 : 0,\n \"aria-label\": ariaLabel,\n \"aria-valuemin\": lo,\n \"aria-valuemax\": hi,\n \"aria-valuenow\": current,\n \"aria-valuetext\": formatValueText?.(current),\n \"aria-disabled\": disabled || undefined,\n onKeyDown,\n },\n };\n}\n"],"mappings":";;;AAIA,MAAM,SAAS,GAAW,IAAY,OAAe,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC;;;;AAKjF,SAAgB,gBAAgB,MAAc,KAAa,KAAa,MAAsB;CAI5F,IAAI,EAAE,MAAM,MAAM,OAAO;CACzB,IAAI,EAAE,OAAO,IAAI,OAAO,MAAM,MAAM,KAAK,GAAG;CAC5C,MAAM,QAAQ,KAAK,MAAM,SAAS,MAAM,OAAO,KAAA,CAAM,QAAQ,CAAC,CAAC,CAAC;CAChE,MAAM,YAAY,QAAQ,MAAM,QAAQ,KAAA,CAAM,QAAQ,CAAC,CAAC;CACxD,MAAM,SAAS,MAAM,KAAK,OAAO,OAAO,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS;CACjF,MAAM,UAAU,YAAY,OAAO,KAAK,IAAI,OAAO,GAAG,KAAK,KAAK,IAAI,OAAO,MAAM,IAAI,MAAM;CAC3F,OAAO,OAAO,QAAQ,QAAQ,CAAC,CAAC;AAClC;;;;;;AAqBA,SAAgB,UAAU,EACxB,OACA,eAAe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CAAC,YAAY,WAAW,UAAU;EACtC,YAAY,MAAM,OAAO;CAC3B,GACA,CAAC,UAAU,WAAW,CACxB;CAEA,MAAM,UAAU,aAAa,UAAwC;EAGnE,IAAI,MAAM,cAAc,oBAAoB,MAAM,SAAS,GACzD,MAAM,cAAc,sBAAsB,MAAM,SAAS;EAE3D,YAAY,UAAU;EACtB,YAAY,KAAK;CACnB,GAAG,CAAC,CAAC;CAEL,MAAM,YAAY,aACf,UAAsC;EACrC,IAAI,UAAU;EACd,MAAM,MAA8B;GAClC,YAAY,UAAU;GACtB,SAAS,UAAU;GACnB,WAAW,UAAU;GACrB,WAAW,UAAU;GACrB,QAAQ,UAAU,SAAS;GAC3B,UAAU,UAAU,SAAS;GAC7B,MAAM;GACN,KAAK;EACP;EACA,IAAI,MAAM,OAAO,KAAK;GACpB,MAAM,eAAe;GACrB,OAAO,IAAI,MAAM,IAAI;EACvB;CACF,GACA;EAAC;EAAU;EAAS;EAAQ;EAAI;EAAI;CAAM,CAC5C;CAEA,OAAO;EACL;EACA;EACA;EACA,KAAK;EACL,KAAK;EACL,MAAM;EACN;;EAEA,YAAY;GACV,KAAK;GACL;GACA;GACA,aAAa;GACb,iBAAiB;GACjB,sBAAsB;EACxB;;EAEA,aAAa;GAEX,MAAM,SAA6B;IACjC,SAAS,UAAU;GACrB;GACA,MAAM;GACN,UAAU,WAAW,KAAK;GAC1B,cAAc;GACd,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB;GACjB,kBAAkB,kBAAkB,OAAO;GAC3C,iBAAiB,YAAY,KAAA;GAC7B;EACF;CACF;AACF"}
1
+ {"version":3,"file":"use-slider.js","names":[],"sources":["../../src/hooks/use-slider.ts"],"sourcesContent":["\"use client\";\n\nimport { type KeyboardEvent, type PointerEvent, useCallback, useRef, useState } from \"react\";\n\nimport { capturePointer, releasePointer } from \"../lib/touch\";\n\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));\n\n/** Nearest legal value on [min, max] for the given step. max counts as a\n * candidate when the step does not divide the range, so a pointer near the end\n * does not snap back onto the last whole step. */\nexport function snapSliderValue(next: number, min: number, max: number, step: number): number {\n // Neither case has a grid to walk. An empty range has exactly one legal\n // point, and a non-positive step only needs a clamp, which also keeps the\n // division below away from zero.\n if (!(max > min)) return min;\n if (!(step > 0)) return clamp(next, min, max);\n const whole = Math.floor(Number(((max - min) / step).toFixed(6)));\n const lastWhole = Number((min + whole * step).toFixed(6));\n const toGrid = clamp(Math.round((next - min) / step) * step + min, min, lastWhole);\n const snapped = lastWhole < max && Math.abs(next - max) <= Math.abs(next - toGrid) ? max : toGrid;\n return Number(snapped.toFixed(6));\n}\n\nexport interface SliderOptions {\n value?: number;\n defaultValue?: number;\n onValueChange?: (value: number) => void;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n \"aria-label\"?: string;\n /** Announced instead of the raw number — pass one when the value carries a\n * unit or a suffix (\"72.5 kg\", \"35%\"); a bare number needs no valueText. */\n formatValueText?: (value: number) => string;\n}\n\n/**\n * Shared value + input plumbing for slider designs: controlled/uncontrolled\n * value, step snapping, pointer-capture drag along a track and arrow-key\n * control. Visuals and motion live in the component; this only owns the number.\n */\nexport function useSlider({\n value,\n defaultValue = 0,\n onValueChange,\n min = 0,\n max = 100,\n step = 1,\n disabled = false,\n \"aria-label\": ariaLabel,\n formatValueText,\n}: SliderOptions) {\n const trackRef = useRef<HTMLDivElement>(null);\n const sliderEl = useRef<HTMLElement | null>(null);\n // The state drives visuals. Move reads this ref instead, so the first\n // pointermove after pointerdown does not have to wait on a re-render.\n const draggingRef = useRef(false);\n const [internal, setInternal] = useState(defaultValue);\n const [dragging, setDragging] = useState(false);\n const controlled = value !== undefined;\n // Collapse inverted or empty ranges and non-positive steps here, so that\n // percent, ticks and the keyboard maths never divide by zero or walk a\n // NaN grid.\n const lo = min;\n const hi = max > min ? max : min;\n const stride = step > 0 ? step : 1;\n const current = clamp(controlled ? value : internal, lo, hi);\n const percent = hi > lo ? ((current - lo) / (hi - lo)) * 100 : 0;\n\n const commit = useCallback(\n (next: number) => {\n const clean = snapSliderValue(next, lo, hi, stride);\n if (!controlled) setInternal(clean);\n onValueChange?.(clean);\n },\n [controlled, onValueChange, lo, hi, stride],\n );\n\n const commitFromX = useCallback(\n (clientX: number) => {\n const rect = trackRef.current?.getBoundingClientRect();\n if (!rect || rect.width === 0) return;\n const ratio = clamp((clientX - rect.left) / rect.width, 0, 1);\n commit(lo + ratio * (hi - lo));\n },\n [commit, lo, hi],\n );\n\n const onPointerDown = useCallback(\n (event: PointerEvent<HTMLDivElement>) => {\n if (disabled) return;\n // Start the drag first: capture is a convenience, and a browser that\n // refuses it — or a test DOM that has no pointer capture at all — must\n // not take the drag down with it.\n draggingRef.current = true;\n setDragging(true);\n capturePointer(event.currentTarget, event.pointerId);\n // A click on the track should land keyboard focus on the handle.\n sliderEl.current?.focus({ preventScroll: true });\n commitFromX(event.clientX);\n },\n [disabled, commitFromX],\n );\n\n const onPointerMove = useCallback(\n (event: PointerEvent<HTMLDivElement>) => {\n if (!draggingRef.current || disabled) return;\n commitFromX(event.clientX);\n },\n [disabled, commitFromX],\n );\n\n const endDrag = useCallback((event: PointerEvent<HTMLDivElement>) => {\n releasePointer(event.currentTarget, event.pointerId);\n draggingRef.current = false;\n setDragging(false);\n }, []);\n\n const onKeyDown = useCallback(\n (event: KeyboardEvent<HTMLElement>) => {\n if (disabled) return;\n const map: Record<string, number> = {\n ArrowRight: current + stride,\n ArrowUp: current + stride,\n ArrowLeft: current - stride,\n ArrowDown: current - stride,\n PageUp: current + stride * 10,\n PageDown: current - stride * 10,\n Home: lo,\n End: hi,\n };\n if (event.key in map) {\n event.preventDefault();\n commit(map[event.key]);\n }\n },\n [disabled, current, stride, lo, hi, commit],\n );\n\n return {\n current,\n percent,\n dragging,\n min: lo,\n max: hi,\n step: stride,\n commit,\n /** Pointer handlers for the track element — drag anywhere on it. */\n trackProps: {\n ref: trackRef,\n onPointerDown,\n onPointerMove,\n onPointerUp: endDrag,\n onPointerCancel: endDrag,\n onLostPointerCapture: endDrag,\n },\n /** ARIA + keyboard props for the focusable slider element. */\n sliderProps: {\n // Callback keeps the handle typed across button/div/motion hosts.\n ref: (node: HTMLElement | null) => {\n sliderEl.current = node;\n },\n role: \"slider\" as const,\n tabIndex: disabled ? -1 : 0,\n \"aria-label\": ariaLabel,\n \"aria-valuemin\": lo,\n \"aria-valuemax\": hi,\n \"aria-valuenow\": current,\n \"aria-valuetext\": formatValueText?.(current),\n \"aria-disabled\": disabled || undefined,\n onKeyDown,\n },\n };\n}\n"],"mappings":";;;;AAMA,MAAM,SAAS,GAAW,IAAY,OAAe,KAAK,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC;;;;AAKjF,SAAgB,gBAAgB,MAAc,KAAa,KAAa,MAAsB;CAI5F,IAAI,EAAE,MAAM,MAAM,OAAO;CACzB,IAAI,EAAE,OAAO,IAAI,OAAO,MAAM,MAAM,KAAK,GAAG;CAC5C,MAAM,QAAQ,KAAK,MAAM,SAAS,MAAM,OAAO,KAAA,CAAM,QAAQ,CAAC,CAAC,CAAC;CAChE,MAAM,YAAY,QAAQ,MAAM,QAAQ,KAAA,CAAM,QAAQ,CAAC,CAAC;CACxD,MAAM,SAAS,MAAM,KAAK,OAAO,OAAO,OAAO,IAAI,IAAI,OAAO,KAAK,KAAK,SAAS;CACjF,MAAM,UAAU,YAAY,OAAO,KAAK,IAAI,OAAO,GAAG,KAAK,KAAK,IAAI,OAAO,MAAM,IAAI,MAAM;CAC3F,OAAO,OAAO,QAAQ,QAAQ,CAAC,CAAC;AAClC;;;;;;AAqBA,SAAgB,UAAU,EACxB,OACA,eAAe,GACf,eACA,MAAM,GACN,MAAM,KACN,OAAO,GACP,WAAW,OACX,cAAc,WACd,mBACgB;CAChB,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,WAAW,OAA2B,IAAI;CAGhD,MAAM,cAAc,OAAO,KAAK;CAChC,MAAM,CAAC,UAAU,eAAe,SAA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,CAAC;CAEL,MAAM,YAAY,aACf,UAAsC;EACrC,IAAI,UAAU;EACd,MAAM,MAA8B;GAClC,YAAY,UAAU;GACtB,SAAS,UAAU;GACnB,WAAW,UAAU;GACrB,WAAW,UAAU;GACrB,QAAQ,UAAU,SAAS;GAC3B,UAAU,UAAU,SAAS;GAC7B,MAAM;GACN,KAAK;EACP;EACA,IAAI,MAAM,OAAO,KAAK;GACpB,MAAM,eAAe;GACrB,OAAO,IAAI,MAAM,IAAI;EACvB;CACF,GACA;EAAC;EAAU;EAAS;EAAQ;EAAI;EAAI;CAAM,CAC5C;CAEA,OAAO;EACL;EACA;EACA;EACA,KAAK;EACL,KAAK;EACL,MAAM;EACN;;EAEA,YAAY;GACV,KAAK;GACL;GACA;GACA,aAAa;GACb,iBAAiB;GACjB,sBAAsB;EACxB;;EAEA,aAAa;GAEX,MAAM,SAA6B;IACjC,SAAS,UAAU;GACrB;GACA,MAAM;GACN,UAAU,WAAW,KAAK;GAC1B,cAAc;GACd,iBAAiB;GACjB,iBAAiB;GACjB,iBAAiB;GACjB,kBAAkB,kBAAkB,OAAO;GAC3C,iBAAiB,YAAY,KAAA;GAC7B;EACF;CACF;AACF"}
@@ -0,0 +1,47 @@
1
+ //#region src/hooks/use-tap-gesture.d.ts
2
+ /** What a pointerdown recorded, read back by the click that ends its gesture. */
3
+ interface TapRecord<S> {
4
+ /** Which input started the gesture. */
5
+ pointerType: string;
6
+ /** What the surface was showing when it started. */
7
+ state: S;
8
+ }
9
+ interface TapGesture<S> {
10
+ /** Record the gesture a pointerdown starts, with the state it starts in. */
11
+ start: (event: {
12
+ pointerType: string;
13
+ }, state: S) => void;
14
+ /** Read the record and clear it. `null` when no pointer is behind this click. */
15
+ take: () => TapRecord<S> | null;
16
+ /** Drop the record: this gesture will never spend it on a click. */
17
+ drop: () => void;
18
+ }
19
+ /**
20
+ * The pointer gesture behind a click, recorded where the click cannot report
21
+ * it. A `click` carries no `pointerType` in the engines that matter, so the
22
+ * `pointerdown` before it is the only thing that says which input activated
23
+ * the control — and whether one did at all, since keyboard activation
24
+ * synthesizes a click with no pointer behind it.
25
+ *
26
+ * State goes in with the record because a click reports that no better: a
27
+ * browser that focuses a control on contact can open the very panel the tap
28
+ * was meant to open, and reading "is it open" at click time then undoes it.
29
+ * What the gesture started against is what it acts on.
30
+ *
31
+ * The record is spent by one click and dropped by everything else, because a
32
+ * record that outlives its gesture is worse than none:
33
+ *
34
+ * - A scroll or an OS gesture takes the touch away — `pointercancel`, no click
35
+ * ever — and the finger would sit in the record until some later click.
36
+ * - That later click is often `Enter` on a keyboard, which arrives with no
37
+ * pointerdown of its own and would inherit the abandoned finger. A keydown
38
+ * is the start of a keyboard activation and never part of a tap, so it drops
39
+ * the record too.
40
+ *
41
+ * Both ends have to be wired by the surface: `drop` on `onPointerCancel` and
42
+ * on `onKeyDown`.
43
+ */
44
+ declare function useTapGesture<S>(): TapGesture<S>;
45
+ //#endregion
46
+ export { TapGesture, TapRecord, useTapGesture };
47
+ //# sourceMappingURL=use-tap-gesture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tap-gesture.d.ts","names":[],"sources":["../../src/hooks/use-tap-gesture.ts"],"mappings":";;UAKiB,UAAU;;EAEzB;;EAEA,OAAO;;UAGQ,WAAW;;EAE1B,QAAQ;IAAS;KAAuB,OAAO;;EAE/C,YAAY,UAAU;;EAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4Bc,cAAc,MAAM,WAAW"}
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { useMemo, useRef } from "react";
3
+ //#region src/hooks/use-tap-gesture.ts
4
+ /**
5
+ * The pointer gesture behind a click, recorded where the click cannot report
6
+ * it. A `click` carries no `pointerType` in the engines that matter, so the
7
+ * `pointerdown` before it is the only thing that says which input activated
8
+ * the control — and whether one did at all, since keyboard activation
9
+ * synthesizes a click with no pointer behind it.
10
+ *
11
+ * State goes in with the record because a click reports that no better: a
12
+ * browser that focuses a control on contact can open the very panel the tap
13
+ * was meant to open, and reading "is it open" at click time then undoes it.
14
+ * What the gesture started against is what it acts on.
15
+ *
16
+ * The record is spent by one click and dropped by everything else, because a
17
+ * record that outlives its gesture is worse than none:
18
+ *
19
+ * - A scroll or an OS gesture takes the touch away — `pointercancel`, no click
20
+ * ever — and the finger would sit in the record until some later click.
21
+ * - That later click is often `Enter` on a keyboard, which arrives with no
22
+ * pointerdown of its own and would inherit the abandoned finger. A keydown
23
+ * is the start of a keyboard activation and never part of a tap, so it drops
24
+ * the record too.
25
+ *
26
+ * Both ends have to be wired by the surface: `drop` on `onPointerCancel` and
27
+ * on `onKeyDown`.
28
+ */
29
+ function useTapGesture() {
30
+ const record = useRef(null);
31
+ return useMemo(() => ({
32
+ start: (event, state) => {
33
+ record.current = {
34
+ pointerType: event.pointerType,
35
+ state
36
+ };
37
+ },
38
+ take: () => {
39
+ const spent = record.current;
40
+ record.current = null;
41
+ return spent;
42
+ },
43
+ drop: () => {
44
+ record.current = null;
45
+ }
46
+ }), []);
47
+ }
48
+ //#endregion
49
+ export { useTapGesture };
50
+
51
+ //# sourceMappingURL=use-tap-gesture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tap-gesture.js","names":[],"sources":["../../src/hooks/use-tap-gesture.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo, useRef } from \"react\";\n\n/** What a pointerdown recorded, read back by the click that ends its gesture. */\nexport interface TapRecord<S> {\n /** Which input started the gesture. */\n pointerType: string;\n /** What the surface was showing when it started. */\n state: S;\n}\n\nexport interface TapGesture<S> {\n /** Record the gesture a pointerdown starts, with the state it starts in. */\n start: (event: { pointerType: string }, state: S) => void;\n /** Read the record and clear it. `null` when no pointer is behind this click. */\n take: () => TapRecord<S> | null;\n /** Drop the record: this gesture will never spend it on a click. */\n drop: () => void;\n}\n\n/**\n * The pointer gesture behind a click, recorded where the click cannot report\n * it. A `click` carries no `pointerType` in the engines that matter, so the\n * `pointerdown` before it is the only thing that says which input activated\n * the control — and whether one did at all, since keyboard activation\n * synthesizes a click with no pointer behind it.\n *\n * State goes in with the record because a click reports that no better: a\n * browser that focuses a control on contact can open the very panel the tap\n * was meant to open, and reading \"is it open\" at click time then undoes it.\n * What the gesture started against is what it acts on.\n *\n * The record is spent by one click and dropped by everything else, because a\n * record that outlives its gesture is worse than none:\n *\n * - A scroll or an OS gesture takes the touch away — `pointercancel`, no click\n * ever — and the finger would sit in the record until some later click.\n * - That later click is often `Enter` on a keyboard, which arrives with no\n * pointerdown of its own and would inherit the abandoned finger. A keydown\n * is the start of a keyboard activation and never part of a tap, so it drops\n * the record too.\n *\n * Both ends have to be wired by the surface: `drop` on `onPointerCancel` and\n * on `onKeyDown`.\n */\nexport function useTapGesture<S>(): TapGesture<S> {\n const record = useRef<TapRecord<S> | null>(null);\n\n return useMemo(\n () => ({\n start: (event, state) => {\n record.current = { pointerType: event.pointerType, state };\n },\n take: () => {\n const spent = record.current;\n record.current = null;\n return spent;\n },\n drop: () => {\n record.current = null;\n },\n }),\n [],\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,gBAAkC;CAChD,MAAM,SAAS,OAA4B,IAAI;CAE/C,OAAO,eACE;EACL,QAAQ,OAAO,UAAU;GACvB,OAAO,UAAU;IAAE,aAAa,MAAM;IAAa;GAAM;EAC3D;EACA,YAAY;GACV,MAAM,QAAQ,OAAO;GACrB,OAAO,UAAU;GACjB,OAAO;EACT;EACA,YAAY;GACV,OAAO,UAAU;EACnB;CACF,IACA,CAAC,CACH;AACF"}
@@ -0,0 +1,15 @@
1
+ //#region src/hooks/use-touch-capable.d.ts
2
+ /**
3
+ * Returns true on devices that can be touched, whatever else they claim.
4
+ *
5
+ * This is not the inverse of `useHoverCapable`: iPadOS Safari browses
6
+ * desktop-class and answers `(hover: hover) and (pointer: fine)` with true
7
+ * while a finger is the only input there is, so anything that treats
8
+ * hover-capable as "no touch here" strands every iPad. Gate the *touch path*
9
+ * of an interaction on this hook and leave hover-only polish on
10
+ * `useHoverCapable`, so a component that opens on hover also opens on tap.
11
+ */
12
+ declare function useTouchCapable(): boolean;
13
+ //#endregion
14
+ export { useTouchCapable };
15
+ //# sourceMappingURL=use-touch-capable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-touch-capable.d.ts","names":[],"sources":["../../src/hooks/use-touch-capable.ts"],"mappings":";;;;;;;;;;;iBAcgB"}
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { useEffect, useState } from "react";
3
+ //#region src/hooks/use-touch-capable.ts
4
+ /**
5
+ * Returns true on devices that can be touched, whatever else they claim.
6
+ *
7
+ * This is not the inverse of `useHoverCapable`: iPadOS Safari browses
8
+ * desktop-class and answers `(hover: hover) and (pointer: fine)` with true
9
+ * while a finger is the only input there is, so anything that treats
10
+ * hover-capable as "no touch here" strands every iPad. Gate the *touch path*
11
+ * of an interaction on this hook and leave hover-only polish on
12
+ * `useHoverCapable`, so a component that opens on hover also opens on tap.
13
+ */
14
+ function useTouchCapable() {
15
+ const [canTouch, setCanTouch] = useState(false);
16
+ useEffect(() => {
17
+ if (typeof window === "undefined") return;
18
+ const mq = window.matchMedia?.("(any-pointer: coarse)");
19
+ const update = () => setCanTouch(Boolean(mq?.matches) || navigator.maxTouchPoints > 0);
20
+ update();
21
+ mq?.addEventListener?.("change", update);
22
+ return () => mq?.removeEventListener?.("change", update);
23
+ }, []);
24
+ return canTouch;
25
+ }
26
+ //#endregion
27
+ export { useTouchCapable };
28
+
29
+ //# sourceMappingURL=use-touch-capable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-touch-capable.js","names":[],"sources":["../../src/hooks/use-touch-capable.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/**\n * Returns true on devices that can be touched, whatever else they claim.\n *\n * This is not the inverse of `useHoverCapable`: iPadOS Safari browses\n * desktop-class and answers `(hover: hover) and (pointer: fine)` with true\n * while a finger is the only input there is, so anything that treats\n * hover-capable as \"no touch here\" strands every iPad. Gate the *touch path*\n * of an interaction on this hook and leave hover-only polish on\n * `useHoverCapable`, so a component that opens on hover also opens on tap.\n */\nexport function useTouchCapable() {\n const [canTouch, setCanTouch] = useState(false);\n\n useEffect(() => {\n if (typeof window === \"undefined\") return;\n const mq = window.matchMedia?.(\"(any-pointer: coarse)\");\n // iPadOS disguises its pointer media queries; maxTouchPoints it reports\n // honestly, which is what makes it the standard iPad tell.\n const update = () => setCanTouch(Boolean(mq?.matches) || navigator.maxTouchPoints > 0);\n update();\n mq?.addEventListener?.(\"change\", update);\n return () => mq?.removeEventListener?.(\"change\", update);\n }, []);\n\n return canTouch;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,kBAAkB;CAChC,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAE9C,gBAAgB;EACd,IAAI,OAAO,WAAW,aAAa;EACnC,MAAM,KAAK,OAAO,aAAa,uBAAuB;EAGtD,MAAM,eAAe,YAAY,QAAQ,IAAI,OAAO,KAAK,UAAU,iBAAiB,CAAC;EACrF,OAAO;EACP,IAAI,mBAAmB,UAAU,MAAM;EACvC,aAAa,IAAI,sBAAsB,UAAU,MAAM;CACzD,GAAG,CAAC,CAAC;CAEL,OAAO;AACT"}