@kumix/ui 0.3.3 → 0.3.5

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 (57) hide show
  1. package/dist/components/agents/agent-activity/activity-row.d.ts +1 -1
  2. package/dist/components/agents/agent-activity/index.d.ts +2 -2
  3. package/dist/components/agents/agent-activity/index.d.ts.map +1 -1
  4. package/dist/components/agents/agent-activity/index.js +9 -3
  5. package/dist/components/agents/agent-activity/index.js.map +1 -1
  6. package/dist/components/agents/loading-states/reasoning-text.d.ts.map +1 -1
  7. package/dist/components/agents/loading-states/reasoning-text.js +7 -39
  8. package/dist/components/agents/loading-states/reasoning-text.js.map +1 -1
  9. package/dist/components/motion/checkbox.d.ts +3 -1
  10. package/dist/components/motion/checkbox.d.ts.map +1 -1
  11. package/dist/components/motion/checkbox.js +2 -1
  12. package/dist/components/motion/checkbox.js.map +1 -1
  13. package/dist/components/motion/combobox/content.d.ts +16 -0
  14. package/dist/components/motion/combobox/content.d.ts.map +1 -0
  15. package/dist/components/motion/combobox/content.js +91 -0
  16. package/dist/components/motion/combobox/content.js.map +1 -0
  17. package/dist/components/motion/combobox/context.d.ts +63 -0
  18. package/dist/components/motion/combobox/context.d.ts.map +1 -0
  19. package/dist/components/motion/combobox/context.js +235 -0
  20. package/dist/components/motion/combobox/context.js.map +1 -0
  21. package/dist/components/motion/combobox/list.d.ts +40 -0
  22. package/dist/components/motion/combobox/list.d.ts.map +1 -0
  23. package/dist/components/motion/combobox/list.js +143 -0
  24. package/dist/components/motion/combobox/list.js.map +1 -0
  25. package/dist/components/motion/combobox/trigger.d.ts +21 -0
  26. package/dist/components/motion/combobox/trigger.d.ts.map +1 -0
  27. package/dist/components/motion/combobox/trigger.js +115 -0
  28. package/dist/components/motion/combobox/trigger.js.map +1 -0
  29. package/dist/components/motion/combobox.d.ts +5 -0
  30. package/dist/components/motion/combobox.js +6 -0
  31. package/dist/components/motion/popover.d.ts.map +1 -1
  32. package/dist/components/motion/popover.js +22 -25
  33. package/dist/components/motion/popover.js.map +1 -1
  34. package/dist/components/motion/signup-form.d.ts +56 -0
  35. package/dist/components/motion/signup-form.d.ts.map +1 -0
  36. package/dist/components/motion/signup-form.js +337 -0
  37. package/dist/components/motion/signup-form.js.map +1 -0
  38. package/dist/components/motion/text-scramble.d.ts +17 -0
  39. package/dist/components/motion/text-scramble.d.ts.map +1 -0
  40. package/dist/components/motion/text-scramble.js +64 -0
  41. package/dist/components/motion/text-scramble.js.map +1 -0
  42. package/dist/components/reui/alert.d.ts +1 -1
  43. package/dist/components/reui/badge.d.ts +1 -1
  44. package/dist/components/reui/frame.d.ts +1 -1
  45. package/dist/components/reui/icon-tile.d.ts +1 -1
  46. package/dist/components/ui/attachment.d.ts +1 -1
  47. package/dist/components/ui/badge.d.ts +1 -1
  48. package/dist/components/ui/bubble.d.ts +1 -1
  49. package/dist/components/ui/button-group.d.ts +1 -1
  50. package/dist/components/ui/button.d.ts +2 -2
  51. package/dist/components/ui/field.d.ts +1 -1
  52. package/dist/components/ui/item.d.ts +1 -1
  53. package/dist/components/ui/sidebar.d.ts +1 -1
  54. package/dist/components/ui/toggle.d.ts +1 -1
  55. package/dist/{types-j36vVGtZ.d.ts → types-kSZH1k8K.d.ts} +11 -1
  56. package/dist/{types-j36vVGtZ.d.ts.map → types-kSZH1k8K.d.ts.map} +1 -1
  57. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"popover.d.ts","names":[],"sources":["../../../src/components/motion/popover.tsx"],"mappings":";;KA8BK;KACA;KACA;UA+IY;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;;EAEhB,UAAU;;EAEV,OAAO;;EAEP,QAAQ;;EAER;;EAEA;;EAEA;EACA;;iBAGc,UACd,UACA,MAAM,gBACN,aACA,cACA,SACA,MACA,OACA,YACA,aACA,aACA,aACC,+BAAY,IAAA;UA0IE;;EAEf,UAAU;;iBAGI,iBAAiB,YAAY,sBAAmB,aAAA,kDAAA;UA2C/C;EACf,UAAU;EACV;;iBAGc,iBAAiB,UAAU,aAAa,sCAAmB"}
1
+ {"version":3,"file":"popover.d.ts","names":[],"sources":["../../../src/components/motion/popover.tsx"],"mappings":";;KA8BK;KACA;KACA;UA8KY;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;;EAEhB,UAAU;;EAEV,OAAO;;EAEP,QAAQ;;EAER;;EAEA;;EAEA;EACA;;iBAGc,UACd,UACA,MAAM,gBACN,aACA,cACA,SACA,MACA,OACA,YACA,aACA,aACA,aACC,+BAAY,IAAA;UA0IE;;EAEf,UAAU;;iBAGI,iBAAiB,YAAY,sBAAmB,aAAA,kDAAA;UA2C/C;EACf,UAAU;EACV;;iBAGc,iBAAiB,UAAU,aAAa,sCAAmB"}
@@ -76,6 +76,25 @@ function clipForProgress(geo, progress, supportsShape) {
76
76
  const rect = rectAtProgress(geo, progress);
77
77
  return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);
78
78
  }
79
+ function roundedRectPath(rect) {
80
+ const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));
81
+ const n = (value) => value.toFixed(3);
82
+ const x1 = rect.x;
83
+ const y1 = rect.y;
84
+ const x2 = rect.x + rect.w;
85
+ const y2 = rect.y + rect.h;
86
+ const arc = `A${n(radius)} ${n(radius)} 0 0 1`;
87
+ return `M${n(x1 + radius)} ${n(y1)}H${n(x2 - radius)}${arc} ${n(x2)} ${n(y1 + radius)}V${n(y2 - radius)}${arc} ${n(x2 - radius)} ${n(y2)}H${n(x1 + radius)}${arc} ${n(x1)} ${n(y2 - radius)}V${n(y1 + radius)}${arc} ${n(x1 + radius)} ${n(y1)}Z`;
88
+ }
89
+ function triggerCutout(geo) {
90
+ return `path(evenodd, "${roundedRectPath({
91
+ x: 0,
92
+ y: 0,
93
+ w: geo.layerW,
94
+ h: geo.layerH,
95
+ r: 0
96
+ })} ${roundedRectPath(geo.trigger)}")`;
97
+ }
79
98
  const PopoverContext = createContext(null);
80
99
  function usePopoverContext(component) {
81
100
  const ctx = useContext(PopoverContext);
@@ -264,7 +283,6 @@ function PopoverContent({ children, className }) {
264
283
  onMouseEnter: openHover,
265
284
  onMouseLeave: scheduleClose
266
285
  } : {};
267
- const maskId = `${gooId}-trigger-cutout`;
268
286
  if (!portalReady) return null;
269
287
  return createPortal(/* @__PURE__ */ jsxs("div", {
270
288
  "data-popover-portal": "",
@@ -279,7 +297,7 @@ function PopoverContent({ children, className }) {
279
297
  width: "0",
280
298
  height: "0",
281
299
  className: "absolute",
282
- children: [/* @__PURE__ */ jsx("title", { children: "Popover visual effects" }), /* @__PURE__ */ jsxs("defs", { children: [/* @__PURE__ */ jsxs("filter", {
300
+ children: [/* @__PURE__ */ jsx("title", { children: "Popover visual effects" }), /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("filter", {
283
301
  id: gooId,
284
302
  x: "-50%",
285
303
  y: "-50%",
@@ -303,27 +321,7 @@ function PopoverContent({ children, className }) {
303
321
  operator: "atop"
304
322
  })
305
323
  ]
306
- }), /* @__PURE__ */ jsxs("mask", {
307
- id: maskId,
308
- maskUnits: "userSpaceOnUse",
309
- maskContentUnits: "userSpaceOnUse",
310
- x: 0,
311
- y: 0,
312
- width: geo.layerW,
313
- height: geo.layerH,
314
- children: [/* @__PURE__ */ jsx("rect", {
315
- width: geo.layerW,
316
- height: geo.layerH,
317
- fill: "white"
318
- }), /* @__PURE__ */ jsx("rect", {
319
- x: geo.trigger.x,
320
- y: geo.trigger.y,
321
- width: geo.trigger.w,
322
- height: geo.trigger.h,
323
- rx: geo.trigger.r,
324
- fill: "black"
325
- })]
326
- })] })]
324
+ }) })]
327
325
  }),
328
326
  /* @__PURE__ */ jsxs("div", {
329
327
  "aria-hidden": true,
@@ -334,8 +332,7 @@ function PopoverContent({ children, className }) {
334
332
  width: geo.layerW,
335
333
  height: geo.layerH,
336
334
  filter: reduce ? void 0 : `url(#${gooId})`,
337
- mask: `url(#${maskId})`,
338
- WebkitMask: `url(#${maskId})`
335
+ clipPath: triggerCutout(geo)
339
336
  },
340
337
  children: [/* @__PURE__ */ jsx("div", {
341
338
  className: "absolute bg-popover",
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/motion/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n animate,\n type MotionValue,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"center\" | \"end\";\ntype TriggerMode = \"click\" | \"hover\";\n\n// This morph needs less bounce than layout motion: too much overshoot makes\n// the liquid neck balloon past the final panel edges.\nconst GOO_OPEN_SPRING = {\n type: \"spring\",\n visualDuration: 0.3,\n bounce: 0.15,\n} as const;\nconst GOO_CLOSE_SPRING = {\n type: \"spring\",\n visualDuration: 0.21,\n bounce: 0.15,\n} as const;\nconst HOVER_CLOSE_DELAY = 120;\nconst CIRCLE_KAPPA = 0.5523;\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n r: number;\n}\ninterface Geo {\n layerW: number;\n layerH: number;\n left: number;\n top: number;\n trigger: Rect;\n panel: Rect;\n}\n\n// Trigger rect and panel rect in a shared local coordinate box.\nfunction buildGeo(\n tW: number,\n tH: number,\n cW: number,\n cH: number,\n side: Side,\n align: Align,\n gap: number,\n panelRadius: number,\n): Geo {\n const py = side === \"bottom\" ? tH + gap : -(gap + cH);\n const px = align === \"start\" ? 0 : align === \"end\" ? tW - cW : (tW - cW) / 2;\n\n const left = Math.min(0, px);\n const top = Math.min(0, py);\n const layerW = Math.max(tW, px + cW) - left;\n const layerH = Math.max(tH, py + cH) - top;\n\n const triggerRadius = Math.min(tH / 2, panelRadius);\n\n return {\n layerW,\n layerH,\n left,\n top,\n trigger: { x: -left, y: -top, w: tW, h: tH, r: triggerRadius },\n panel: { x: px - left, y: py - top, w: cW, h: cH, r: panelRadius },\n };\n}\n\nfunction rectAtProgress(geo: Geo, progress: number): Rect {\n const trigger = geo.trigger;\n const panel = geo.panel;\n\n return {\n x: lerp(trigger.x, panel.x, progress),\n y: lerp(trigger.y, panel.y, progress),\n w: lerp(trigger.w, panel.w, progress),\n h: lerp(trigger.h, panel.h, progress),\n r: lerp(trigger.r, panel.r, progress),\n };\n}\n\nfunction insetFor(rect: Rect, layerW: number, layerH: number) {\n const top = rect.y;\n const right = layerW - (rect.x + rect.w);\n const bottom = layerH - (rect.y + rect.h);\n const left = rect.x;\n return `inset(${top}px ${right}px ${bottom}px ${left}px round ${rect.r}px)`;\n}\n\nfunction roundedRectShape(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const control = radius * CIRCLE_KAPPA;\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const px = (value: number) => `${value.toFixed(3)}px`;\n\n return (\n `shape(from ${px(x1 + radius)} ${px(y1)}, ` +\n `line to ${px(x2 - radius)} ${px(y1)}, ` +\n `curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, ` +\n `line to ${px(x2)} ${px(y2 - radius)}, ` +\n `curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, ` +\n `line to ${px(x1 + radius)} ${px(y2)}, ` +\n `curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, ` +\n `line to ${px(x1)} ${px(y1 + radius)}, ` +\n `curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, ` +\n \"close)\"\n );\n}\n\nfunction clipForProgress(geo: Geo, progress: number, supportsShape: boolean) {\n const rect = rectAtProgress(geo, progress);\n return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n openHover: () => void;\n scheduleClose: () => void;\n triggerMode: TriggerMode;\n side: Side;\n align: Align;\n gap: number;\n panelRadius: number;\n gooStrength: number;\n reduce: boolean;\n gooId: string;\n contentId: string;\n progress: MotionValue<number>;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | null>(null);\n\nfunction usePopoverContext(component: string) {\n const ctx = useContext(PopoverContext);\n if (!ctx) throw new Error(`${component} must be used within <Popover>`);\n return ctx;\n}\n\nexport interface PopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** How the popover is summoned. Default \"click\". */\n trigger?: TriggerMode;\n /** Which side of the trigger the panel oozes out of. Default \"bottom\". */\n side?: Side;\n /** Alignment along the trigger's edge. Default \"center\". */\n align?: Align;\n /** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */\n sideOffset?: number;\n /** Corner radius of the open panel, in px. Default 16. */\n panelRadius?: number;\n /** Blur radius feeding the goo filter — higher melts more. Default 8. */\n gooStrength?: number;\n className?: string;\n}\n\nexport function Popover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n trigger = \"click\",\n side = \"bottom\",\n align = \"center\",\n sideOffset = 14,\n panelRadius = 16,\n gooStrength = 8,\n className,\n}: PopoverProps) {\n const reduce = useReducedMotion() ?? false;\n const gooId = useId().replace(/:/g, \"\");\n const contentId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const progress = useMotionValue(defaultOpen ? 1 : 0);\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openHover = useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose, setOpen]);\n\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);\n }, [cancelClose, setOpen]);\n\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n useEffect(() => () => cancelClose(), [cancelClose]);\n\n useEffect(() => {\n const animation = animate(\n progress,\n open ? 1 : 0,\n reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING,\n );\n return () => animation.stop();\n }, [open, progress, reduce]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n // The panel is portalled, so both trees participate in outside detection.\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (\n rootRef.current &&\n !rootRef.current.contains(target) &&\n !contentRef.current?.contains(target)\n )\n setOpen(false);\n };\n window.addEventListener(\"keydown\", onKey);\n if (trigger === \"click\") window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open, setOpen, trigger]);\n\n const ctx = useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n triggerMode: trigger,\n side,\n align,\n gap: sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n }),\n [\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n trigger,\n side,\n align,\n sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n ],\n );\n\n const hoverHandlers =\n trigger === \"hover\" ? { onMouseEnter: openHover, onMouseLeave: scheduleClose } : {};\n\n return (\n <PopoverContext.Provider value={ctx}>\n <div\n ref={rootRef}\n className={cn(\"relative isolate inline-flex\", className)}\n {...hoverHandlers}\n >\n {children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface PopoverTriggerProps {\n /** A single focusable element (e.g. a Button) that opens the popover. */\n children: ReactElement;\n}\n\nexport function PopoverTrigger({ children }: PopoverTriggerProps) {\n const ctx = usePopoverContext(\"PopoverTrigger\");\n\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n const childRef = (childProps as { ref?: Ref<HTMLElement> }).ref;\n\n const compose =\n (name: string, handler: () => void) => (event: { defaultPrevented?: boolean }) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n if (!event.defaultPrevented) handler();\n };\n\n const handlers: Record<string, unknown> =\n ctx.triggerMode === \"hover\"\n ? {\n onFocus: compose(\"onFocus\", ctx.openHover),\n onBlur: compose(\"onBlur\", ctx.scheduleClose),\n }\n : { onClick: compose(\"onClick\", ctx.toggle) };\n\n return cloneElement(child, {\n ...handlers,\n ref: mergeRefs(childRef, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\n // Above the goo layer (z-[-1]) so the neck reads behind it.\n className: cn(\"relative z-0\", childProps.className as string | undefined),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n \"data-state\": ctx.open ? \"open\" : \"closed\",\n });\n}\n\nconst ALIGN_ORIGIN: Record<Align, string> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nexport interface PopoverContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function PopoverContent({ children, className }: PopoverContentProps) {\n const ctx = usePopoverContext(\"PopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n const {\n side,\n align,\n gap,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n open,\n triggerMode,\n openHover,\n scheduleClose,\n } = ctx;\n\n const measureRef = contentRef;\n const blobRef = useRef<HTMLDivElement>(null);\n const clipRef = useRef<HTMLDivElement>(null);\n const geoRef = useRef<Geo | null>(null);\n const supportsShapeRef = useRef(false);\n const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);\n\n useEffect(() => setPortalReady(true), []);\n\n const geo = useMemo(\n () =>\n buildGeo(\n layout?.trigger.width ?? 0,\n layout?.trigger.height ?? 0,\n layout?.content.width ?? 0,\n layout?.content.height ?? 0,\n side,\n align,\n gap,\n panelRadius,\n ),\n [layout, side, align, gap, panelRadius],\n );\n\n // Morph the same clip on the goo body and the content, so the whole popover\n // oozes as one and the text reveals with it.\n const render = useCallback((g: Geo | null, p: number) => {\n if (!g || g.layerW === 0) return;\n const clip = clipForProgress(g, p, supportsShapeRef.current);\n if (blobRef.current) blobRef.current.style.clipPath = clip;\n if (clipRef.current) clipRef.current.style.clipPath = clip;\n }, []);\n\n useLayoutEffect(() => {\n supportsShapeRef.current =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"clip-path\", \"shape(from 0px 0px, line to 1px 1px, close)\");\n geoRef.current = geo;\n render(geo, progress.get());\n }, [geo, progress, render]);\n\n useMotionValueEvent(progress, \"change\", (p) => render(geoRef.current, p));\n\n const hoverHandlers =\n triggerMode === \"hover\" ? { onMouseEnter: openHover, onMouseLeave: scheduleClose } : {};\n const maskId = `${gooId}-trigger-cutout`;\n\n // Match the server and first client render, then attach the portal after\n // hydration. This preserves SSR without regenerating the page on the client.\n if (!portalReady) return null;\n\n return createPortal(\n <div\n data-popover-portal=\"\"\n className=\"pointer-events-none fixed top-0 left-0 isolate z-9999 size-0\"\n style={{\n visibility: layout ? \"visible\" : \"hidden\",\n transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`,\n }}\n >\n {/* Goo filter: blur, sharpen the alpha back into solid shapes, then lay\n the crisp original on top so blobs merge with liquid edges. The mask\n removes the real trigger area so this top-layer copy never covers its\n label or focus ring. */}\n <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n <title>Popover visual effects</title>\n <defs>\n <filter id={gooId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation={gooStrength} result=\"blur\" />\n <feColorMatrix\n in=\"blur\"\n mode=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10\"\n result=\"goo\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n </filter>\n <mask\n id={maskId}\n maskUnits=\"userSpaceOnUse\"\n maskContentUnits=\"userSpaceOnUse\"\n x={0}\n y={0}\n width={geo.layerW}\n height={geo.layerH}\n >\n <rect width={geo.layerW} height={geo.layerH} fill=\"white\" />\n <rect\n x={geo.trigger.x}\n y={geo.trigger.y}\n width={geo.trigger.w}\n height={geo.trigger.h}\n rx={geo.trigger.r}\n fill=\"black\"\n />\n </mask>\n </defs>\n </svg>\n\n {/* Goo body: static trigger pill + morphing blob. */}\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-[-1]\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n filter: reduce ? undefined : `url(#${gooId})`,\n mask: `url(#${maskId})`,\n WebkitMask: `url(#${maskId})`,\n }}\n >\n <div\n className=\"absolute bg-popover\"\n style={{\n left: geo.trigger.x,\n top: geo.trigger.y,\n width: geo.trigger.w,\n height: geo.trigger.h,\n borderRadius: geo.trigger.r,\n }}\n />\n <div\n ref={blobRef}\n className=\"absolute inset-0 bg-popover\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n }}\n />\n </div>\n\n {/* Content is clipped by the same morph. The portal wrapper stays\n pointer-transparent; only the fully open panel accepts interaction. */}\n <div\n className=\"pointer-events-none absolute z-10\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n }}\n >\n <div\n ref={clipRef}\n inert={!open}\n className=\"absolute inset-0\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n >\n <div\n ref={measureRef}\n id={contentId}\n role=\"dialog\"\n {...hoverHandlers}\n style={{\n position: \"absolute\",\n left: geo.panel.x,\n top: geo.panel.y,\n transformOrigin: `${ALIGN_ORIGIN[align]} ${side === \"bottom\" ? \"top\" : \"bottom\"}`,\n }}\n className={cn(\n \"w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none\",\n className,\n )}\n >\n {children}\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;AAoCA,MAAM,kBAAkB;CACtB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,mBAAmB;CACvB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAErB,MAAM,QAAQ,GAAW,GAAW,MAAc,KAAK,IAAI,KAAK;AAmBhE,SAAS,SACP,IACA,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OAAO;IAC7B;IAXF,UAAA,CAaE,oBAAC,OAAD;KACE,WAAU;KACV,OAAO;MACL,MAAM,IAAI,QAAQ;MAClB,KAAK,IAAI,QAAQ;MACjB,OAAO,IAAI,QAAQ;MACnB,QAAQ,IAAI,QAAQ;MACpB,cAAc,IAAI,QAAQ;KAC5B;IACD,CAAA,GACD,oBAAC,OAAD;KACE,KAAK;KACL,WAAU;KACV,OAAO,EACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK,EACtD;IACD,CAAA,CACE;;GAIL,oBAAC,OAAD;IACE,WAAU;IACV,OAAO;KACL,MAAM,IAAI;KACV,KAAK,IAAI;KACT,OAAO,IAAI;KACX,QAAQ,IAAI;IACd;IAEA,UAAA,oBAAC,OAAD;KACE,KAAK;KACL,OAAO,CAAC;KACR,WAAU;KACV,OAAO;MACL,UAAU,gBAAgB,KAAK,SAAS,IAAI,GAAG,KAAK;MACpD,eAAe,OAAO,SAAS;KACjC;KAEA,UAAA,oBAAC,OAAD;MACE,KAAK;MACL,IAAI;MACJ,MAAK;MACL,GAAI;MACJ,OAAO;OACL,UAAU;OACV,MAAM,IAAI,MAAM;OAChB,KAAK,IAAI,MAAM;OACf,iBAAiB,GAAG,aAAa,OAAO,GAAG,SAAS,WAAW,QAAQ;MACzE;MACA,WAAW,GACT,0EACA,SACF;MAEC;KACE,CAAA;IACF,CAAA;GACF,CAAA;EACF;CACL,CAAA,GAAA,SAAS,IACX;AACF"}
1
+ {"version":3,"file":"popover.js","names":[],"sources":["../../../src/components/motion/popover.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n type Ref,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n animate,\n type MotionValue,\n useMotionValue,\n useMotionValueEvent,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { usePopoverPortalPosition } from \"./popover-position\";\n\ntype Side = \"top\" | \"bottom\";\ntype Align = \"start\" | \"center\" | \"end\";\ntype TriggerMode = \"click\" | \"hover\";\n\n// This morph needs less bounce than layout motion: too much overshoot makes\n// the liquid neck balloon past the final panel edges.\nconst GOO_OPEN_SPRING = {\n type: \"spring\",\n visualDuration: 0.3,\n bounce: 0.15,\n} as const;\nconst GOO_CLOSE_SPRING = {\n type: \"spring\",\n visualDuration: 0.21,\n bounce: 0.15,\n} as const;\nconst HOVER_CLOSE_DELAY = 120;\nconst CIRCLE_KAPPA = 0.5523;\n\nconst lerp = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n r: number;\n}\ninterface Geo {\n layerW: number;\n layerH: number;\n left: number;\n top: number;\n trigger: Rect;\n panel: Rect;\n}\n\n// Trigger rect and panel rect in a shared local coordinate box.\nfunction buildGeo(\n tW: number,\n tH: number,\n cW: number,\n cH: number,\n side: Side,\n align: Align,\n gap: number,\n panelRadius: number,\n): Geo {\n const py = side === \"bottom\" ? tH + gap : -(gap + cH);\n const px = align === \"start\" ? 0 : align === \"end\" ? tW - cW : (tW - cW) / 2;\n\n const left = Math.min(0, px);\n const top = Math.min(0, py);\n const layerW = Math.max(tW, px + cW) - left;\n const layerH = Math.max(tH, py + cH) - top;\n\n const triggerRadius = Math.min(tH / 2, panelRadius);\n\n return {\n layerW,\n layerH,\n left,\n top,\n trigger: { x: -left, y: -top, w: tW, h: tH, r: triggerRadius },\n panel: { x: px - left, y: py - top, w: cW, h: cH, r: panelRadius },\n };\n}\n\nfunction rectAtProgress(geo: Geo, progress: number): Rect {\n const trigger = geo.trigger;\n const panel = geo.panel;\n\n return {\n x: lerp(trigger.x, panel.x, progress),\n y: lerp(trigger.y, panel.y, progress),\n w: lerp(trigger.w, panel.w, progress),\n h: lerp(trigger.h, panel.h, progress),\n r: lerp(trigger.r, panel.r, progress),\n };\n}\n\nfunction insetFor(rect: Rect, layerW: number, layerH: number) {\n const top = rect.y;\n const right = layerW - (rect.x + rect.w);\n const bottom = layerH - (rect.y + rect.h);\n const left = rect.x;\n return `inset(${top}px ${right}px ${bottom}px ${left}px round ${rect.r}px)`;\n}\n\nfunction roundedRectShape(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const control = radius * CIRCLE_KAPPA;\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const px = (value: number) => `${value.toFixed(3)}px`;\n\n return (\n `shape(from ${px(x1 + radius)} ${px(y1)}, ` +\n `line to ${px(x2 - radius)} ${px(y1)}, ` +\n `curve to ${px(x2)} ${px(y1 + radius)} with ${px(x2 - radius + control)} ${px(y1)} / ${px(x2)} ${px(y1 + radius - control)}, ` +\n `line to ${px(x2)} ${px(y2 - radius)}, ` +\n `curve to ${px(x2 - radius)} ${px(y2)} with ${px(x2)} ${px(y2 - radius + control)} / ${px(x2 - radius + control)} ${px(y2)}, ` +\n `line to ${px(x1 + radius)} ${px(y2)}, ` +\n `curve to ${px(x1)} ${px(y2 - radius)} with ${px(x1 + radius - control)} ${px(y2)} / ${px(x1)} ${px(y2 - radius + control)}, ` +\n `line to ${px(x1)} ${px(y1 + radius)}, ` +\n `curve to ${px(x1 + radius)} ${px(y1)} with ${px(x1)} ${px(y1 + radius - control)} / ${px(x1 + radius - control)} ${px(y1)}, ` +\n \"close)\"\n );\n}\n\nfunction clipForProgress(geo: Geo, progress: number, supportsShape: boolean) {\n const rect = rectAtProgress(geo, progress);\n return supportsShape ? roundedRectShape(rect) : insetFor(rect, geo.layerW, geo.layerH);\n}\n\nfunction roundedRectPath(rect: Rect) {\n const radius = Math.max(0, Math.min(rect.r, rect.w / 2, rect.h / 2));\n const n = (value: number) => value.toFixed(3);\n const x1 = rect.x;\n const y1 = rect.y;\n const x2 = rect.x + rect.w;\n const y2 = rect.y + rect.h;\n const arc = `A${n(radius)} ${n(radius)} 0 0 1`;\n\n // A zero radius makes every arc degenerate to a line, so this also draws\n // plain rectangles.\n return (\n `M${n(x1 + radius)} ${n(y1)}` +\n `H${n(x2 - radius)}${arc} ${n(x2)} ${n(y1 + radius)}` +\n `V${n(y2 - radius)}${arc} ${n(x2 - radius)} ${n(y2)}` +\n `H${n(x1 + radius)}${arc} ${n(x1)} ${n(y2 - radius)}` +\n `V${n(y1 + radius)}${arc} ${n(x1 + radius)} ${n(y1)}Z`\n );\n}\n\n// The goo layer is portalled above the page, so its copy of the trigger pill\n// would cover the real trigger's label and focus ring. Punching the trigger\n// back out keeps the real one visible and clips the blur to the layer box.\n// This is a clip path rather than a CSS mask on purpose: WebKit silently\n// ignores `mask: url(#id)` pointing at an SVG <mask> element, which left the\n// label hidden behind the goo in Safari.\nfunction triggerCutout(geo: Geo) {\n const layer = { x: 0, y: 0, w: geo.layerW, h: geo.layerH, r: 0 };\n return `path(evenodd, \"${roundedRectPath(layer)} ${roundedRectPath(geo.trigger)}\")`;\n}\n\ninterface PopoverContextValue {\n open: boolean;\n setOpen: (open: boolean) => void;\n toggle: () => void;\n openHover: () => void;\n scheduleClose: () => void;\n triggerMode: TriggerMode;\n side: Side;\n align: Align;\n gap: number;\n panelRadius: number;\n gooStrength: number;\n reduce: boolean;\n gooId: string;\n contentId: string;\n progress: MotionValue<number>;\n triggerRef: React.MutableRefObject<HTMLElement | null>;\n contentRef: React.MutableRefObject<HTMLDivElement | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | null>(null);\n\nfunction usePopoverContext(component: string) {\n const ctx = useContext(PopoverContext);\n if (!ctx) throw new Error(`${component} must be used within <Popover>`);\n return ctx;\n}\n\nexport interface PopoverProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Uncontrolled initial open state. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n /** How the popover is summoned. Default \"click\". */\n trigger?: TriggerMode;\n /** Which side of the trigger the panel oozes out of. Default \"bottom\". */\n side?: Side;\n /** Alignment along the trigger's edge. Default \"center\". */\n align?: Align;\n /** Gap between trigger and panel, in px — the length of the gooey neck. Default 14. */\n sideOffset?: number;\n /** Corner radius of the open panel, in px. Default 16. */\n panelRadius?: number;\n /** Blur radius feeding the goo filter — higher melts more. Default 8. */\n gooStrength?: number;\n className?: string;\n}\n\nexport function Popover({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n trigger = \"click\",\n side = \"bottom\",\n align = \"center\",\n sideOffset = 14,\n panelRadius = 16,\n gooStrength = 8,\n className,\n}: PopoverProps) {\n const reduce = useReducedMotion() ?? false;\n const gooId = useId().replace(/:/g, \"\");\n const contentId = useId();\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLElement | null>(null);\n const contentRef = useRef<HTMLDivElement | null>(null);\n const closeTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const progress = useMotionValue(defaultOpen ? 1 : 0);\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const controlled = controlledOpen !== undefined;\n const open = controlled ? controlledOpen : internalOpen;\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!controlled) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [controlled, onOpenChange],\n );\n\n const cancelClose = useCallback(() => {\n if (closeTimer.current) {\n clearTimeout(closeTimer.current);\n closeTimer.current = null;\n }\n }, []);\n\n const openHover = useCallback(() => {\n cancelClose();\n setOpen(true);\n }, [cancelClose, setOpen]);\n\n const scheduleClose = useCallback(() => {\n cancelClose();\n closeTimer.current = setTimeout(() => setOpen(false), HOVER_CLOSE_DELAY);\n }, [cancelClose, setOpen]);\n\n const toggle = useCallback(() => setOpen(!open), [setOpen, open]);\n\n useEffect(() => () => cancelClose(), [cancelClose]);\n\n useEffect(() => {\n const animation = animate(\n progress,\n open ? 1 : 0,\n reduce ? { duration: 0 } : open ? GOO_OPEN_SPRING : GOO_CLOSE_SPRING,\n );\n return () => animation.stop();\n }, [open, progress, reduce]);\n\n useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => e.key === \"Escape\" && setOpen(false);\n // The panel is portalled, so both trees participate in outside detection.\n const onPointer = (e: PointerEvent) => {\n const target = e.target as Node;\n if (\n rootRef.current &&\n !rootRef.current.contains(target) &&\n !contentRef.current?.contains(target)\n )\n setOpen(false);\n };\n window.addEventListener(\"keydown\", onKey);\n if (trigger === \"click\") window.addEventListener(\"pointerdown\", onPointer);\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n window.removeEventListener(\"pointerdown\", onPointer);\n };\n }, [open, setOpen, trigger]);\n\n const ctx = useMemo<PopoverContextValue>(\n () => ({\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n triggerMode: trigger,\n side,\n align,\n gap: sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n }),\n [\n open,\n setOpen,\n toggle,\n openHover,\n scheduleClose,\n trigger,\n side,\n align,\n sideOffset,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n ],\n );\n\n const hoverHandlers =\n trigger === \"hover\" ? { onMouseEnter: openHover, onMouseLeave: scheduleClose } : {};\n\n return (\n <PopoverContext.Provider value={ctx}>\n <div\n ref={rootRef}\n className={cn(\"relative isolate inline-flex\", className)}\n {...hoverHandlers}\n >\n {children}\n </div>\n </PopoverContext.Provider>\n );\n}\n\nfunction mergeRefs<T>(...refs: Array<Ref<T> | undefined>) {\n return (node: T | null) => {\n for (const ref of refs) {\n if (typeof ref === \"function\") ref(node);\n else if (ref && typeof ref === \"object\")\n (ref as React.MutableRefObject<T | null>).current = node;\n }\n };\n}\n\nexport interface PopoverTriggerProps {\n /** A single focusable element (e.g. a Button) that opens the popover. */\n children: ReactElement;\n}\n\nexport function PopoverTrigger({ children }: PopoverTriggerProps) {\n const ctx = usePopoverContext(\"PopoverTrigger\");\n\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childProps = child.props;\n const childRef = (childProps as { ref?: Ref<HTMLElement> }).ref;\n\n const compose =\n (name: string, handler: () => void) => (event: { defaultPrevented?: boolean }) => {\n (childProps[name] as ((e: unknown) => void) | undefined)?.(event);\n if (!event.defaultPrevented) handler();\n };\n\n const handlers: Record<string, unknown> =\n ctx.triggerMode === \"hover\"\n ? {\n onFocus: compose(\"onFocus\", ctx.openHover),\n onBlur: compose(\"onBlur\", ctx.scheduleClose),\n }\n : { onClick: compose(\"onClick\", ctx.toggle) };\n\n return cloneElement(child, {\n ...handlers,\n ref: mergeRefs(childRef, (node: HTMLElement | null) => {\n ctx.triggerRef.current = node;\n }),\n // Above the goo layer (z-[-1]) so the neck reads behind it.\n className: cn(\"relative z-0\", childProps.className as string | undefined),\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": ctx.open,\n \"aria-controls\": ctx.open ? ctx.contentId : undefined,\n \"data-state\": ctx.open ? \"open\" : \"closed\",\n });\n}\n\nconst ALIGN_ORIGIN: Record<Align, string> = {\n start: \"left\",\n center: \"center\",\n end: \"right\",\n};\n\nexport interface PopoverContentProps {\n children: ReactNode;\n className?: string;\n}\n\nexport function PopoverContent({ children, className }: PopoverContentProps) {\n const ctx = usePopoverContext(\"PopoverContent\");\n const [portalReady, setPortalReady] = useState(false);\n const {\n side,\n align,\n gap,\n panelRadius,\n gooStrength,\n reduce,\n gooId,\n contentId,\n progress,\n triggerRef,\n contentRef,\n open,\n triggerMode,\n openHover,\n scheduleClose,\n } = ctx;\n\n const measureRef = contentRef;\n const blobRef = useRef<HTMLDivElement>(null);\n const clipRef = useRef<HTMLDivElement>(null);\n const geoRef = useRef<Geo | null>(null);\n const supportsShapeRef = useRef(false);\n const layout = usePopoverPortalPosition(triggerRef, measureRef, portalReady);\n\n useEffect(() => setPortalReady(true), []);\n\n const geo = useMemo(\n () =>\n buildGeo(\n layout?.trigger.width ?? 0,\n layout?.trigger.height ?? 0,\n layout?.content.width ?? 0,\n layout?.content.height ?? 0,\n side,\n align,\n gap,\n panelRadius,\n ),\n [layout, side, align, gap, panelRadius],\n );\n\n // Morph the same clip on the goo body and the content, so the whole popover\n // oozes as one and the text reveals with it.\n const render = useCallback((g: Geo | null, p: number) => {\n if (!g || g.layerW === 0) return;\n const clip = clipForProgress(g, p, supportsShapeRef.current);\n if (blobRef.current) blobRef.current.style.clipPath = clip;\n if (clipRef.current) clipRef.current.style.clipPath = clip;\n }, []);\n\n useLayoutEffect(() => {\n supportsShapeRef.current =\n typeof CSS !== \"undefined\" &&\n typeof CSS.supports === \"function\" &&\n CSS.supports(\"clip-path\", \"shape(from 0px 0px, line to 1px 1px, close)\");\n geoRef.current = geo;\n render(geo, progress.get());\n }, [geo, progress, render]);\n\n useMotionValueEvent(progress, \"change\", (p) => render(geoRef.current, p));\n\n const hoverHandlers =\n triggerMode === \"hover\" ? { onMouseEnter: openHover, onMouseLeave: scheduleClose } : {};\n\n // Match the server and first client render, then attach the portal after\n // hydration. This preserves SSR without regenerating the page on the client.\n if (!portalReady) return null;\n\n return createPortal(\n <div\n data-popover-portal=\"\"\n className=\"pointer-events-none fixed top-0 left-0 isolate z-9999 size-0\"\n style={{\n visibility: layout ? \"visible\" : \"hidden\",\n transform: `translate3d(${layout?.trigger.left ?? 0}px, ${layout?.trigger.top ?? 0}px, 0)`,\n }}\n >\n {/* Goo filter: blur, sharpen the alpha back into solid shapes, then lay\n the crisp original on top so blobs merge with liquid edges. */}\n <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n <title>Popover visual effects</title>\n <defs>\n <filter id={gooId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur in=\"SourceGraphic\" stdDeviation={gooStrength} result=\"blur\" />\n <feColorMatrix\n in=\"blur\"\n mode=\"matrix\"\n values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 22 -10\"\n result=\"goo\"\n />\n <feComposite in=\"SourceGraphic\" in2=\"goo\" operator=\"atop\" />\n </filter>\n </defs>\n </svg>\n\n {/* Goo body: static trigger pill + morphing blob. */}\n <div\n aria-hidden\n className=\"pointer-events-none absolute z-[-1]\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n filter: reduce ? undefined : `url(#${gooId})`,\n clipPath: triggerCutout(geo),\n }}\n >\n <div\n className=\"absolute bg-popover\"\n style={{\n left: geo.trigger.x,\n top: geo.trigger.y,\n width: geo.trigger.w,\n height: geo.trigger.h,\n borderRadius: geo.trigger.r,\n }}\n />\n <div\n ref={blobRef}\n className=\"absolute inset-0 bg-popover\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n }}\n />\n </div>\n\n {/* Content is clipped by the same morph. The portal wrapper stays\n pointer-transparent; only the fully open panel accepts interaction. */}\n <div\n className=\"pointer-events-none absolute z-10\"\n style={{\n left: geo.left,\n top: geo.top,\n width: geo.layerW,\n height: geo.layerH,\n }}\n >\n <div\n ref={clipRef}\n inert={!open}\n className=\"absolute inset-0\"\n style={{\n clipPath: clipForProgress(geo, progress.get(), false),\n pointerEvents: open ? \"auto\" : \"none\",\n }}\n >\n <div\n ref={measureRef}\n id={contentId}\n role=\"dialog\"\n {...hoverHandlers}\n style={{\n position: \"absolute\",\n left: geo.panel.x,\n top: geo.panel.y,\n transformOrigin: `${ALIGN_ORIGIN[align]} ${side === \"bottom\" ? \"top\" : \"bottom\"}`,\n }}\n className={cn(\n \"w-max max-w-[min(92vw,20rem)] p-4 text-popover-foreground outline-none\",\n className,\n )}\n >\n {children}\n </div>\n </div>\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;AAoCA,MAAM,kBAAkB;CACtB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,mBAAmB;CACvB,MAAM;CACN,gBAAgB;CAChB,QAAQ;AACV;AACA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAErB,MAAM,QAAQ,GAAW,GAAW,MAAc,KAAK,IAAI,KAA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AO;OACL,UAAU;OACV,MAAM,IAAI,MAAM;OAChB,KAAK,IAAI,MAAM;OACf,iBAAiB,GAAG,aAAa,OAAO,GAAG,SAAS,WAAW,QAAQ;MACzE;MACA,WAAW,GACT,0EACA,SACF;MAEC;KACE,CAAA;IACF,CAAA;GACF,CAAA;EACF;CACL,CAAA,GAAA,SAAS,IACX;AACF"}
@@ -0,0 +1,56 @@
1
+ import { ReactNode } from "react";
2
+ //#region src/components/motion/signup-form.d.ts
3
+ type SignUpStatus = "idle" | "loading" | "success" | "error";
4
+ type SignUpValues = {
5
+ name: string;
6
+ email: string;
7
+ password: string;
8
+ confirmPassword: string;
9
+ terms: boolean;
10
+ };
11
+ type SignUpErrors = Partial<Record<keyof SignUpValues, string>>;
12
+ type SignUpFormClassNames = {
13
+ root?: string;
14
+ header?: string;
15
+ title?: string;
16
+ description?: string;
17
+ fields?: string;
18
+ strength?: string;
19
+ terms?: string;
20
+ submit?: string;
21
+ footer?: string;
22
+ };
23
+ interface SignUpFormProps {
24
+ /** Controlled values. Omit for uncontrolled. */
25
+ values?: SignUpValues;
26
+ defaultValues?: Partial<SignUpValues>;
27
+ onValuesChange?: (values: SignUpValues) => void;
28
+ /** Called with valid values only. Return a promise to drive the button state. */
29
+ onSubmit?: (values: SignUpValues) => void | Promise<void>;
30
+ /** Replace the built-in rules — return a message per invalid field. */
31
+ validate?: (values: SignUpValues) => SignUpErrors;
32
+ /** Controlled submit state. Omit to let the form track it. */
33
+ status?: SignUpStatus;
34
+ /** Form-level failure message, shown above the submit button. */
35
+ errorMessage?: string;
36
+ title?: ReactNode;
37
+ description?: ReactNode;
38
+ submitLabel?: string;
39
+ footer?: ReactNode;
40
+ /** Show the password strength meter. */
41
+ strengthMeter?: boolean;
42
+ className?: string;
43
+ classNames?: SignUpFormClassNames;
44
+ }
45
+ /**
46
+ * Length-weighted strength score, 0-4. NIST SP 800-63B advises against
47
+ * composition requirements and treats length as the dominant factor, so extra
48
+ * character classes only nudge the score — they can't rescue a short password.
49
+ * This is a heuristic for feedback, not entropy estimation; pair it with a
50
+ * breach-list check server-side for anything real.
51
+ */
52
+ declare function passwordStrength(password: string): number;
53
+ declare function SignUpForm({ values: valuesProp, defaultValues, onValuesChange, onSubmit, validate, status: statusProp, errorMessage, title, description, submitLabel, footer, strengthMeter, className, classNames }: SignUpFormProps): import("react").JSX.Element;
54
+ //#endregion
55
+ export { SignUpErrors, SignUpForm, SignUpFormClassNames, SignUpFormProps, SignUpStatus, SignUpValues, passwordStrength };
56
+ //# sourceMappingURL=signup-form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup-form.d.ts","names":[],"sources":["../../../src/components/motion/signup-form.tsx"],"mappings":";;KAYY;KAEA;EACV;EACA;EACA;EACA;EACA;;KAGU,eAAe,QAAQ,aAAa;KAEpC;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGe;;EAEf,SAAS;EACT,gBAAgB,QAAQ;EACxB,kBAAkB,QAAQ;;EAE1B,YAAY,QAAQ,wBAAwB;;EAE5C,YAAY,QAAQ,iBAAiB;;EAErC,SAAS;;EAET;EACA,QAAQ;EACR,cAAc;EACd;EACA,SAAS;;EAET;EACA;EACA,aAAa;;;;;;;;;iBAkCC,iBAAiB;iBA+CjB,aACd,QAAQ,YACR,eACA,gBACA,UACA,UACA,QAAQ,YACR,cACA,OACA,aACA,aACA,QACA,eACA,WACA,cACC,kCAAe,IAAA"}
@@ -0,0 +1,337 @@
1
+ "use client";
2
+ import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
3
+ import { StatefulButton } from "./button/stateful.js";
4
+ import "./button/index.js";
5
+ import { Checkbox } from "./checkbox.js";
6
+ import { Input } from "./input.js";
7
+ import { useCallback, useId, useMemo, useState } from "react";
8
+ import { cn } from "@kumix/utils";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
11
+ import { Eye, EyeOff, Lock, Mail, User } from "lucide-react";
12
+ //#region src/components/motion/signup-form.tsx
13
+ const EMPTY_VALUES = {
14
+ name: "",
15
+ email: "",
16
+ password: "",
17
+ confirmPassword: "",
18
+ terms: false
19
+ };
20
+ const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
21
+ const MIN_PASSWORD_LENGTH = 8;
22
+ const STRENGTH_LABELS = [
23
+ "Too short",
24
+ "Weak",
25
+ "Fair",
26
+ "Good",
27
+ "Strong"
28
+ ];
29
+ const STRENGTH_COLORS = [
30
+ "bg-destructive",
31
+ "bg-destructive",
32
+ "bg-amber-500",
33
+ "bg-amber-400",
34
+ "bg-(--color-success)"
35
+ ];
36
+ /**
37
+ * Length-weighted strength score, 0-4. NIST SP 800-63B advises against
38
+ * composition requirements and treats length as the dominant factor, so extra
39
+ * character classes only nudge the score — they can't rescue a short password.
40
+ * This is a heuristic for feedback, not entropy estimation; pair it with a
41
+ * breach-list check server-side for anything real.
42
+ */
43
+ function passwordStrength(password) {
44
+ if (password.length < MIN_PASSWORD_LENGTH) return 0;
45
+ let score = 1;
46
+ if (password.length >= 12) score += 1;
47
+ if (password.length >= 16) score += 1;
48
+ if ([
49
+ /[a-z]/,
50
+ /[A-Z]/,
51
+ /\d/,
52
+ /[^A-Za-z0-9]/
53
+ ].filter((pattern) => pattern.test(password)).length >= 3) score += 1;
54
+ return Math.min(score, 4);
55
+ }
56
+ function defaultValidate(values) {
57
+ const errors = {};
58
+ if (!values.name.trim()) errors.name = "Enter your name.";
59
+ if (!values.email.trim()) errors.email = "Enter your email.";
60
+ else if (!EMAIL_PATTERN.test(values.email)) errors.email = "That doesn't look like an email address.";
61
+ if (!values.password) errors.password = "Choose a password.";
62
+ else if (values.password.length < MIN_PASSWORD_LENGTH) errors.password = `Use at least ${MIN_PASSWORD_LENGTH} characters.`;
63
+ if (!values.confirmPassword) errors.confirmPassword = "Confirm your password.";
64
+ else if (values.confirmPassword !== values.password) errors.confirmPassword = "Passwords don't match.";
65
+ if (!values.terms) errors.terms = "Accept the terms to continue.";
66
+ return errors;
67
+ }
68
+ function SignUpForm({ values: valuesProp, defaultValues, onValuesChange, onSubmit, validate, status: statusProp, errorMessage, title = "Create your account", description = "Start building in under a minute.", submitLabel = "Create account", footer, strengthMeter = true, className, classNames }) {
69
+ const reduce = useReducedMotion();
70
+ const baseId = useId();
71
+ const controlled = valuesProp !== void 0;
72
+ const [internalValues, setInternalValues] = useState({
73
+ ...EMPTY_VALUES,
74
+ ...defaultValues
75
+ });
76
+ const values = controlled ? valuesProp : internalValues;
77
+ const [internalStatus, setInternalStatus] = useState("idle");
78
+ const status = statusProp ?? internalStatus;
79
+ const [revealPassword, setRevealPassword] = useState(false);
80
+ const [touched, setTouched] = useState({});
81
+ const errors = useMemo(() => (validate ?? defaultValidate)(values), [values, validate]);
82
+ const setValue = useCallback((key, next) => {
83
+ const nextValues = {
84
+ ...values,
85
+ [key]: next
86
+ };
87
+ if (!controlled) {
88
+ setInternalValues(nextValues);
89
+ if (statusProp === void 0) setInternalStatus((current) => current === "success" || current === "error" ? "idle" : current);
90
+ }
91
+ onValuesChange?.(nextValues);
92
+ }, [
93
+ controlled,
94
+ onValuesChange,
95
+ statusProp,
96
+ values
97
+ ]);
98
+ const touch = useCallback((key) => {
99
+ setTouched((prev) => prev[key] ? prev : {
100
+ ...prev,
101
+ [key]: true
102
+ });
103
+ }, []);
104
+ /** Error to render for a field — hidden until the field has been touched. */
105
+ const shownError = (key) => touched[key] ? errors[key] : void 0;
106
+ /** Success check draws only once a touched field is non-empty and valid. */
107
+ const isValid = (key) => Boolean(touched[key]) && !errors[key] && Boolean(values[key]);
108
+ const strength = passwordStrength(values.password);
109
+ const showStrength = strengthMeter && values.password.length > 0;
110
+ const isSubmitting = status === "loading";
111
+ const handleSubmit = async (event) => {
112
+ event.preventDefault();
113
+ setTouched({
114
+ name: true,
115
+ email: true,
116
+ password: true,
117
+ confirmPassword: true,
118
+ terms: true
119
+ });
120
+ if (Object.keys(errors).length > 0) return;
121
+ if (!onSubmit) return;
122
+ if (statusProp === void 0) setInternalStatus("loading");
123
+ try {
124
+ await onSubmit(values);
125
+ if (statusProp === void 0) setInternalStatus("success");
126
+ } catch {
127
+ if (statusProp === void 0) setInternalStatus("error");
128
+ }
129
+ };
130
+ const termsErrorId = `${baseId}-terms-error`;
131
+ const formErrorId = `${baseId}-form-error`;
132
+ return /* @__PURE__ */ jsxs("form", {
133
+ noValidate: true,
134
+ onSubmit: handleSubmit,
135
+ className: cn("flex w-full max-w-sm flex-col gap-5 rounded-3xl border border-border p-6", className, classNames?.root),
136
+ children: [
137
+ title || description ? /* @__PURE__ */ jsxs("div", {
138
+ className: cn("flex flex-col gap-1", classNames?.header),
139
+ children: [title ? /* @__PURE__ */ jsx("h2", {
140
+ className: cn("font-semibold text-foreground text-xl tracking-tight", classNames?.title),
141
+ children: title
142
+ }) : null, description ? /* @__PURE__ */ jsx("p", {
143
+ className: cn("text-muted-foreground text-sm", classNames?.description),
144
+ children: description
145
+ }) : null]
146
+ }) : null,
147
+ /* @__PURE__ */ jsxs("div", {
148
+ className: cn("flex flex-col gap-4", classNames?.fields),
149
+ children: [
150
+ /* @__PURE__ */ jsx(Input, {
151
+ label: "Name",
152
+ autoComplete: "name",
153
+ placeholder: "Ada Lovelace",
154
+ leftIcon: /* @__PURE__ */ jsx(User, {}),
155
+ disabled: isSubmitting,
156
+ value: values.name,
157
+ onChange: (next) => setValue("name", next),
158
+ onBlur: () => touch("name"),
159
+ error: shownError("name"),
160
+ success: isValid("name")
161
+ }),
162
+ /* @__PURE__ */ jsx(Input, {
163
+ label: "Email",
164
+ type: "email",
165
+ inputMode: "email",
166
+ autoComplete: "email",
167
+ placeholder: "you@example.com",
168
+ leftIcon: /* @__PURE__ */ jsx(Mail, {}),
169
+ disabled: isSubmitting,
170
+ value: values.email,
171
+ onChange: (next) => setValue("email", next),
172
+ onBlur: () => touch("email"),
173
+ error: shownError("email"),
174
+ success: isValid("email")
175
+ }),
176
+ /* @__PURE__ */ jsxs("div", {
177
+ className: "flex flex-col gap-2",
178
+ children: [/* @__PURE__ */ jsx(Input, {
179
+ label: "Password",
180
+ type: revealPassword ? "text" : "password",
181
+ autoComplete: "new-password",
182
+ placeholder: "At least 8 characters",
183
+ leftIcon: /* @__PURE__ */ jsx(Lock, {}),
184
+ rightIcon: /* @__PURE__ */ jsx("button", {
185
+ type: "button",
186
+ disabled: isSubmitting,
187
+ onClick: () => setRevealPassword((prev) => !prev),
188
+ "aria-label": revealPassword ? "Hide password" : "Show password",
189
+ className: "text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground",
190
+ children: revealPassword ? /* @__PURE__ */ jsx(EyeOff, {}) : /* @__PURE__ */ jsx(Eye, {})
191
+ }),
192
+ disabled: isSubmitting,
193
+ value: values.password,
194
+ onChange: (next) => setValue("password", next),
195
+ onBlur: () => touch("password"),
196
+ error: shownError("password")
197
+ }), /* @__PURE__ */ jsx(AnimatePresence, {
198
+ initial: false,
199
+ children: showStrength ? /* @__PURE__ */ jsxs(motion.div, {
200
+ initial: reduce ? { opacity: 0 } : {
201
+ opacity: 0,
202
+ y: -4
203
+ },
204
+ animate: {
205
+ opacity: 1,
206
+ y: 0
207
+ },
208
+ exit: reduce ? { opacity: 0 } : {
209
+ opacity: 0,
210
+ y: -4
211
+ },
212
+ transition: {
213
+ duration: .18,
214
+ ease: EASE_OUT
215
+ },
216
+ className: cn("flex flex-col gap-1.5 px-1", classNames?.strength),
217
+ children: [/* @__PURE__ */ jsx("div", {
218
+ className: "flex gap-1.5",
219
+ "aria-hidden": true,
220
+ children: [
221
+ 0,
222
+ 1,
223
+ 2,
224
+ 3
225
+ ].map((index) => /* @__PURE__ */ jsx("span", {
226
+ className: "h-1 flex-1 overflow-hidden rounded-full bg-muted-foreground/20",
227
+ children: /* @__PURE__ */ jsx(motion.span, {
228
+ initial: false,
229
+ animate: { scaleX: index < strength ? 1 : 0 },
230
+ transition: reduce ? { duration: 0 } : SPRING_LAYOUT,
231
+ className: cn("block h-full w-full origin-left rounded-full", STRENGTH_COLORS[strength])
232
+ })
233
+ }, index))
234
+ }), /* @__PURE__ */ jsxs("p", {
235
+ "aria-live": "polite",
236
+ className: "text-muted-foreground text-xs",
237
+ children: ["Password strength: ", STRENGTH_LABELS[strength]]
238
+ })]
239
+ }) : null
240
+ })]
241
+ }),
242
+ /* @__PURE__ */ jsx(Input, {
243
+ label: "Confirm password",
244
+ type: revealPassword ? "text" : "password",
245
+ autoComplete: "new-password",
246
+ placeholder: "Re-enter your password",
247
+ leftIcon: /* @__PURE__ */ jsx(Lock, {}),
248
+ disabled: isSubmitting,
249
+ value: values.confirmPassword,
250
+ onChange: (next) => setValue("confirmPassword", next),
251
+ onBlur: () => touch("confirmPassword"),
252
+ error: shownError("confirmPassword"),
253
+ success: isValid("confirmPassword")
254
+ })
255
+ ]
256
+ }),
257
+ /* @__PURE__ */ jsxs("div", {
258
+ className: cn("flex flex-col gap-1.5", classNames?.terms),
259
+ children: [/* @__PURE__ */ jsx(Checkbox, {
260
+ checked: values.terms,
261
+ disabled: isSubmitting,
262
+ onCheckedChange: (next) => {
263
+ setValue("terms", next);
264
+ touch("terms");
265
+ },
266
+ label: "I agree to the Terms and Privacy Policy",
267
+ "aria-describedby": shownError("terms") ? termsErrorId : void 0
268
+ }), /* @__PURE__ */ jsx(AnimatePresence, {
269
+ initial: false,
270
+ children: shownError("terms") ? /* @__PURE__ */ jsx(motion.p, {
271
+ id: termsErrorId,
272
+ role: "alert",
273
+ initial: reduce ? { opacity: 0 } : {
274
+ opacity: 0,
275
+ y: -4,
276
+ filter: "blur(4px)"
277
+ },
278
+ animate: {
279
+ opacity: 1,
280
+ y: 0,
281
+ filter: "blur(0px)"
282
+ },
283
+ exit: reduce ? { opacity: 0 } : {
284
+ opacity: 0,
285
+ y: -4,
286
+ filter: "blur(4px)"
287
+ },
288
+ transition: { duration: .2 },
289
+ className: "px-1 text-destructive text-xs",
290
+ children: shownError("terms")
291
+ }) : null
292
+ })]
293
+ }),
294
+ /* @__PURE__ */ jsx(AnimatePresence, {
295
+ initial: false,
296
+ children: errorMessage ? /* @__PURE__ */ jsx(motion.p, {
297
+ id: formErrorId,
298
+ role: "alert",
299
+ initial: reduce ? { opacity: 0 } : {
300
+ opacity: 0,
301
+ y: -4
302
+ },
303
+ animate: {
304
+ opacity: 1,
305
+ y: 0
306
+ },
307
+ exit: reduce ? { opacity: 0 } : {
308
+ opacity: 0,
309
+ y: -4
310
+ },
311
+ transition: { duration: .2 },
312
+ className: "rounded-2xl border border-destructive/30 bg-destructive/10 px-3 py-2 text-destructive text-xs",
313
+ children: errorMessage
314
+ }) : null
315
+ }),
316
+ /* @__PURE__ */ jsx(StatefulButton, {
317
+ type: "submit",
318
+ size: "lg",
319
+ state: status,
320
+ loadingText: "Creating account",
321
+ successText: "Account created",
322
+ errorText: "Try again",
323
+ "aria-describedby": errorMessage ? formErrorId : void 0,
324
+ className: cn("w-full", classNames?.submit),
325
+ children: submitLabel
326
+ }),
327
+ footer ? /* @__PURE__ */ jsx("div", {
328
+ className: cn("text-center text-muted-foreground text-sm", classNames?.footer),
329
+ children: footer
330
+ }) : null
331
+ ]
332
+ });
333
+ }
334
+ //#endregion
335
+ export { SignUpForm, passwordStrength };
336
+
337
+ //# sourceMappingURL=signup-form.js.map