@kumix/ui 0.3.7 → 0.3.9

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 (186) hide show
  1. package/README.md +26 -25
  2. package/dist/cascader-types-BnH6wYD-.d.ts +183 -0
  3. package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -0
  4. package/dist/components/agents/ai-sidebar.js +3 -5
  5. package/dist/components/agents/ai-sidebar.js.map +1 -1
  6. package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
  7. package/dist/components/motion/animated-sidebar.js +12 -3
  8. package/dist/components/motion/animated-sidebar.js.map +1 -1
  9. package/dist/components/motion/attachment-upload.d.ts.map +1 -1
  10. package/dist/components/motion/attachment-upload.js +9 -5
  11. package/dist/components/motion/attachment-upload.js.map +1 -1
  12. package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
  13. package/dist/components/motion/bottom-sheet.js +77 -74
  14. package/dist/components/motion/bottom-sheet.js.map +1 -1
  15. package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
  16. package/dist/components/motion/center-morph-modal.js +82 -88
  17. package/dist/components/motion/center-morph-modal.js.map +1 -1
  18. package/dist/components/motion/combobox/content.js +1 -1
  19. package/dist/components/motion/combobox/context.d.ts +6 -0
  20. package/dist/components/motion/combobox/context.d.ts.map +1 -1
  21. package/dist/components/motion/combobox/context.js +1 -233
  22. package/dist/components/motion/combobox/list.js +1 -1
  23. package/dist/components/motion/combobox/trigger.js +7 -8
  24. package/dist/components/motion/combobox/trigger.js.map +1 -1
  25. package/dist/components/motion/combobox.js +1 -1
  26. package/dist/components/motion/command-palette.d.ts.map +1 -1
  27. package/dist/components/motion/command-palette.js +62 -45
  28. package/dist/components/motion/command-palette.js.map +1 -1
  29. package/dist/components/motion/drawer.d.ts.map +1 -1
  30. package/dist/components/motion/drawer.js +30 -30
  31. package/dist/components/motion/drawer.js.map +1 -1
  32. package/dist/components/motion/loader.js +20 -22
  33. package/dist/components/motion/loader.js.map +1 -1
  34. package/dist/components/motion/morphing-modal.d.ts.map +1 -1
  35. package/dist/components/motion/morphing-modal.js +83 -83
  36. package/dist/components/motion/morphing-modal.js.map +1 -1
  37. package/dist/components/motion/morphing-search.d.ts +28 -0
  38. package/dist/components/motion/morphing-search.d.ts.map +1 -0
  39. package/dist/components/motion/morphing-search.js +422 -0
  40. package/dist/components/motion/morphing-search.js.map +1 -0
  41. package/dist/components/motion/project-folder.js +20 -20
  42. package/dist/components/motion/project-folder.js.map +1 -1
  43. package/dist/components/reui/alert.d.ts +1 -1
  44. package/dist/components/reui/badge.d.ts +1 -1
  45. package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
  46. package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
  47. package/dist/components/reui/cascader/cascader-async.js +549 -0
  48. package/dist/components/reui/cascader/cascader-async.js.map +1 -0
  49. package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
  50. package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
  51. package/dist/components/reui/cascader/cascader-columns.js +135 -0
  52. package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
  53. package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
  54. package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
  55. package/dist/components/reui/cascader/cascader-context.js +59 -0
  56. package/dist/components/reui/cascader/cascader-context.js.map +1 -0
  57. package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
  58. package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
  59. package/dist/components/reui/cascader/cascader-footer.js +456 -0
  60. package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
  61. package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
  62. package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
  63. package/dist/components/reui/cascader/cascader-i18n.js +68 -0
  64. package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
  65. package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
  66. package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
  67. package/dist/components/reui/cascader/cascader-item.js +530 -0
  68. package/dist/components/reui/cascader/cascader-item.js.map +1 -0
  69. package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
  70. package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
  71. package/dist/components/reui/cascader/cascader-lib.js +576 -0
  72. package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
  73. package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
  74. package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
  75. package/dist/components/reui/cascader/cascader-nav.js +312 -0
  76. package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
  77. package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
  78. package/dist/components/reui/cascader/cascader-types.js +2 -0
  79. package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
  80. package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
  81. package/dist/components/reui/cascader/cascader-virtual.js +240 -0
  82. package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
  83. package/dist/components/reui/cascader/cascader.d.ts +322 -0
  84. package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
  85. package/dist/components/reui/cascader/cascader.js +1459 -0
  86. package/dist/components/reui/cascader/cascader.js.map +1 -0
  87. package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
  88. package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
  89. package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
  90. package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
  91. package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
  92. package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
  93. package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
  94. package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
  95. package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
  96. package/dist/components/reui/filters/filters-advanced.js +1191 -0
  97. package/dist/components/reui/filters/filters-advanced.js.map +1 -0
  98. package/dist/components/reui/filters/filters-builder.d.ts +43 -0
  99. package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
  100. package/dist/components/reui/filters/filters-builder.js +152 -0
  101. package/dist/components/reui/filters/filters-builder.js.map +1 -0
  102. package/dist/components/reui/filters/filters-chip.d.ts +79 -0
  103. package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
  104. package/dist/components/reui/filters/filters-chip.js +553 -0
  105. package/dist/components/reui/filters/filters-chip.js.map +1 -0
  106. package/dist/components/reui/filters/filters-context.d.ts +290 -0
  107. package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
  108. package/dist/components/reui/filters/filters-context.js +277 -0
  109. package/dist/components/reui/filters/filters-context.js.map +1 -0
  110. package/dist/components/reui/filters/filters-date.d.ts +43 -0
  111. package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
  112. package/dist/components/reui/filters/filters-date.js +143 -0
  113. package/dist/components/reui/filters/filters-date.js.map +1 -0
  114. package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
  115. package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
  116. package/dist/components/reui/filters/filters-dnd.js +454 -0
  117. package/dist/components/reui/filters/filters-dnd.js.map +1 -0
  118. package/dist/components/reui/filters/filters-draft.d.ts +2 -0
  119. package/dist/components/reui/filters/filters-draft.js +128 -0
  120. package/dist/components/reui/filters/filters-draft.js.map +1 -0
  121. package/dist/components/reui/filters/filters-editors.d.ts +91 -0
  122. package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
  123. package/dist/components/reui/filters/filters-editors.js +773 -0
  124. package/dist/components/reui/filters/filters-editors.js.map +1 -0
  125. package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
  126. package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
  127. package/dist/components/reui/filters/filters-i18n.js +127 -0
  128. package/dist/components/reui/filters/filters-i18n.js.map +1 -0
  129. package/dist/components/reui/filters/filters-lib.d.ts +171 -0
  130. package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
  131. package/dist/components/reui/filters/filters-lib.js +336 -0
  132. package/dist/components/reui/filters/filters-lib.js.map +1 -0
  133. package/dist/components/reui/filters/filters-operators.d.ts +49 -0
  134. package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
  135. package/dist/components/reui/filters/filters-operators.js +300 -0
  136. package/dist/components/reui/filters/filters-operators.js.map +1 -0
  137. package/dist/components/reui/filters/filters-query.d.ts +132 -0
  138. package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
  139. package/dist/components/reui/filters/filters-query.js +476 -0
  140. package/dist/components/reui/filters/filters-query.js.map +1 -0
  141. package/dist/components/reui/filters/filters-types.d.ts +452 -0
  142. package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
  143. package/dist/components/reui/filters/filters-types.js +2 -0
  144. package/dist/components/reui/filters/filters.d.ts +114 -0
  145. package/dist/components/reui/filters/filters.d.ts.map +1 -0
  146. package/dist/components/reui/filters/filters.js +638 -0
  147. package/dist/components/reui/filters/filters.js.map +1 -0
  148. package/dist/components/reui/gantt/gantt-bar.js +1 -1
  149. package/dist/components/reui/gantt/gantt-nav.js +1 -1
  150. package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
  151. package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
  152. package/dist/components/reui/gantt/gantt-view.js +1 -1
  153. package/dist/components/ui/button.d.ts +1 -1
  154. package/dist/components/ui/checkbox.js +1 -1
  155. package/dist/components/ui/checkbox.js.map +1 -1
  156. package/dist/components/ui/field.js +2 -2
  157. package/dist/components/ui/field.js.map +1 -1
  158. package/dist/components/ui/radio-group.js +1 -1
  159. package/dist/components/ui/radio-group.js.map +1 -1
  160. package/dist/components/ui/sidebar.js +1 -1
  161. package/dist/components/ui/switch.js +1 -1
  162. package/dist/components/ui/switch.js.map +1 -1
  163. package/dist/context-BizvUNZv.js +298 -0
  164. package/dist/context-BizvUNZv.js.map +1 -0
  165. package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
  166. package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
  167. package/dist/hooks/use-on-open.d.ts +18 -0
  168. package/dist/hooks/use-on-open.d.ts.map +1 -0
  169. package/dist/hooks/use-on-open.js +27 -0
  170. package/dist/hooks/use-on-open.js.map +1 -0
  171. package/dist/hooks/use-row-cursor.d.ts +39 -0
  172. package/dist/hooks/use-row-cursor.d.ts.map +1 -0
  173. package/dist/hooks/use-row-cursor.js +77 -0
  174. package/dist/hooks/use-row-cursor.js.map +1 -0
  175. package/dist/lib/text-shimmer.d.ts +2 -2
  176. package/dist/lib/text-shimmer.d.ts.map +1 -1
  177. package/dist/lib/text-shimmer.js +2 -2
  178. package/dist/lib/text-shimmer.js.map +1 -1
  179. package/dist/presence-gate-BekdC4Bo.js +24 -0
  180. package/dist/presence-gate-BekdC4Bo.js.map +1 -0
  181. package/package.json +11 -11
  182. package/dist/components/motion/combobox/context.js.map +0 -1
  183. package/dist/components/reui/filters.d.ts +0 -176
  184. package/dist/components/reui/filters.d.ts.map +0 -1
  185. package/dist/components/reui/filters.js +0 -1223
  186. package/dist/components/reui/filters.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { TOUCH_GESTURE_CONTENT_CLASS } from "../../lib/touch.js";
3
3
  import { EASE_DRAWER } from "../../lib/ease.js";
4
+ import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
4
5
  import { useEffect, useId, useRef, useState } from "react";
5
6
  import { cn } from "@kumix/utils";
6
7
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -82,82 +83,84 @@ function BottomSheet({ open, onOpenChange, snapPoints = [.5, .92], defaultSnap =
82
83
  const snapValue = snapPoints[snap];
83
84
  const heightStyle = snapValue === "auto" ? { maxHeight: "92vh" } : { height: `${snapValue * 100}vh` };
84
85
  if (!mounted) return null;
85
- return createPortal(/* @__PURE__ */ jsx(AnimatePresence, { children: open ? /* @__PURE__ */ jsxs("div", {
86
- className: "pointer-events-none fixed inset-0 z-50",
87
- children: [/* @__PURE__ */ jsx(motion.button, {
88
- type: "button",
89
- "aria-label": "Close bottom sheet",
90
- initial: { opacity: 0 },
91
- animate: { opacity: 1 },
92
- exit: { opacity: 0 },
93
- transition: DRAWER,
94
- onClick: () => onOpenChange(false),
95
- className: "pointer-events-auto absolute inset-0 bg-background/40 backdrop-blur-sm"
96
- }), /* @__PURE__ */ jsxs(motion.div, {
97
- ref: sheetRef,
98
- drag: "y",
99
- dragControls,
100
- dragListener: false,
101
- dragConstraints: {
102
- top: 0,
103
- bottom: 0
104
- },
105
- dragElastic: {
106
- top: .02,
107
- bottom: .4
108
- },
109
- dragMomentum: false,
110
- onDragEnd,
111
- initial: reduce ? {
112
- y: 0,
113
- opacity: 0
114
- } : { y: "100%" },
115
- animate: reduce ? {
116
- y: 0,
117
- opacity: 1
118
- } : { y: 0 },
119
- exit: reduce ? {
120
- y: 0,
121
- opacity: 0
122
- } : { y: "100%" },
123
- transition: reduce ? {
124
- duration: .18,
125
- ease: EASE_DRAWER
126
- } : DRAWER,
127
- onAnimationComplete: () => {
128
- if (sheetRef.current) heightRef.current = sheetRef.current.offsetHeight;
129
- },
130
- style: heightStyle,
131
- className: cn("pointer-events-auto absolute right-0 bottom-0 left-0 mx-auto flex max-w-2xl flex-col overflow-hidden rounded-t-3xl will-change-transform", "border border-border bg-background shadow-xl", className),
132
- role: "dialog",
133
- "aria-modal": "true",
134
- "aria-labelledby": title ? titleId : void 0,
135
- "aria-describedby": description ? descriptionId : void 0,
136
- "aria-label": title ? void 0 : "Bottom sheet",
137
- children: [/* @__PURE__ */ jsxs("div", {
138
- className: "flex flex-col items-center px-4 pt-3 pb-2",
139
- children: [/* @__PURE__ */ jsx("div", {
140
- onPointerDown: (event) => dragControls.start(event),
141
- className: cn("flex cursor-grab touch-none items-center justify-center py-1 active:cursor-grabbing", TOUCH_GESTURE_CONTENT_CLASS),
142
- children: /* @__PURE__ */ jsx("div", { className: "h-1.5 w-10 rounded-full bg-muted-foreground/40" })
143
- }), title || description ? /* @__PURE__ */ jsxs("div", {
144
- className: "mt-2 w-full",
145
- children: [title ? /* @__PURE__ */ jsx("h2", {
146
- id: titleId,
147
- className: "font-semibold text-base text-foreground",
148
- children: title
149
- }) : null, description ? /* @__PURE__ */ jsx("p", {
150
- id: descriptionId,
151
- className: "mt-0.5 text-muted-foreground text-sm",
152
- children: description
153
- }) : null]
86
+ return createPortal(/* @__PURE__ */ jsxs(AnimatePresence, { children: [open ? /* @__PURE__ */ jsx(PresenceGate, { children: ({ gate }) => /* @__PURE__ */ jsx(motion.button, {
87
+ type: "button",
88
+ "aria-label": "Close bottom sheet",
89
+ initial: { opacity: 0 },
90
+ animate: { opacity: 1 },
91
+ exit: { opacity: 0 },
92
+ transition: DRAWER,
93
+ ...gate,
94
+ onClick: () => onOpenChange(false),
95
+ className: "pointer-events-auto fixed inset-0 z-50 bg-background/40 backdrop-blur-sm"
96
+ }) }, "backdrop") : null, open ? /* @__PURE__ */ jsx(PresenceGate, { children: ({ gate }) => /* @__PURE__ */ jsxs(motion.div, {
97
+ ref: sheetRef,
98
+ drag: "y",
99
+ dragControls,
100
+ dragListener: false,
101
+ dragConstraints: {
102
+ top: 0,
103
+ bottom: 0
104
+ },
105
+ dragElastic: {
106
+ top: .02,
107
+ bottom: .4
108
+ },
109
+ dragMomentum: false,
110
+ onDragEnd,
111
+ initial: reduce ? {
112
+ y: 0,
113
+ opacity: 0
114
+ } : { y: "100%" },
115
+ animate: reduce ? {
116
+ y: 0,
117
+ opacity: 1
118
+ } : { y: 0 },
119
+ exit: reduce ? {
120
+ y: 0,
121
+ opacity: 0
122
+ } : { y: "100%" },
123
+ transition: reduce ? {
124
+ duration: .18,
125
+ ease: EASE_DRAWER
126
+ } : DRAWER,
127
+ onAnimationComplete: () => {
128
+ if (sheetRef.current) heightRef.current = sheetRef.current.offsetHeight;
129
+ },
130
+ ...gate,
131
+ style: {
132
+ ...heightStyle,
133
+ ...gate.style
134
+ },
135
+ className: cn("pointer-events-auto fixed right-0 bottom-0 left-0 z-50 mx-auto flex max-w-2xl flex-col overflow-hidden rounded-t-3xl will-change-transform", "border border-border bg-background shadow-xl", className),
136
+ role: "dialog",
137
+ "aria-modal": "true",
138
+ "aria-labelledby": title ? titleId : void 0,
139
+ "aria-describedby": description ? descriptionId : void 0,
140
+ "aria-label": title ? void 0 : "Bottom sheet",
141
+ children: [/* @__PURE__ */ jsxs("div", {
142
+ className: "flex flex-col items-center px-4 pt-3 pb-2",
143
+ children: [/* @__PURE__ */ jsx("div", {
144
+ onPointerDown: (event) => dragControls.start(event),
145
+ className: cn("flex cursor-grab touch-none items-center justify-center py-1 active:cursor-grabbing", TOUCH_GESTURE_CONTENT_CLASS),
146
+ children: /* @__PURE__ */ jsx("div", { className: "h-1.5 w-10 rounded-full bg-muted-foreground/40" })
147
+ }), title || description ? /* @__PURE__ */ jsxs("div", {
148
+ className: "mt-2 w-full",
149
+ children: [title ? /* @__PURE__ */ jsx("h2", {
150
+ id: titleId,
151
+ className: "font-semibold text-base text-foreground",
152
+ children: title
153
+ }) : null, description ? /* @__PURE__ */ jsx("p", {
154
+ id: descriptionId,
155
+ className: "mt-0.5 text-muted-foreground text-sm",
156
+ children: description
154
157
  }) : null]
155
- }), /* @__PURE__ */ jsx("div", {
156
- className: "flex-1 overflow-y-auto overscroll-contain px-4 pb-6",
157
- children
158
- })]
158
+ }) : null]
159
+ }), /* @__PURE__ */ jsx("div", {
160
+ className: "flex-1 overflow-y-auto overscroll-contain px-4 pb-6",
161
+ children
159
162
  })]
160
- }) : null }), document.body);
163
+ }) }, "sheet") : null] }), document.body);
161
164
  }
162
165
  //#endregion
163
166
  export { BottomSheet };
@@ -1 +1 @@
1
- {"version":3,"file":"bottom-sheet.js","names":[],"sources":["../../../src/components/motion/bottom-sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport {\n AnimatePresence,\n motion,\n type PanInfo,\n useDragControls,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_DRAWER } from \"../../lib/ease\";\nimport { TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\n// Vaul-style glide: a long, fully-damped tween reads smoother than a spring on\n// open — no settle/overshoot, just one clean decel. Same curve drives the\n// backdrop fade so the surface and scrim move as one.\nconst DRAWER = { duration: 0.5, ease: EASE_DRAWER } as const;\n\nexport interface BottomSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Heights (0-1 = fraction of viewport, or \"auto\"). First entry is default. */\n snapPoints?: (number | \"auto\")[];\n defaultSnap?: number;\n title?: string;\n description?: string;\n children?: ReactNode;\n className?: string;\n /** Min drag distance (px) past current snap to dismiss. */\n dismissThreshold?: number;\n}\n\nexport function BottomSheet({\n open,\n onOpenChange,\n snapPoints = [0.5, 0.92],\n defaultSnap = 0,\n title,\n description,\n children,\n className,\n dismissThreshold = 120,\n}: BottomSheetProps) {\n const [snap, setSnap] = useState(defaultSnap);\n const [mounted, setMounted] = useState(false);\n const dragControls = useDragControls();\n const sheetRef = useRef<HTMLDivElement>(null);\n const reduce = useReducedMotion();\n const heightRef = useRef(0);\n const uid = useId();\n const titleId = `${uid}-title`;\n const descriptionId = `${uid}-description`;\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n if (open) setSnap(defaultSnap);\n }, [open, defaultSnap]);\n\n // Lock background scroll while open. overflow:hidden alone is ignored by\n // iOS Safari — boundary scrolls inside the sheet chain to the page, which\n // scrolls underneath and ends up somewhere else on close. position:fixed\n // is the lock that actually holds; restore the scroll position after.\n useEffect(() => {\n if (!open) return;\n const body = document.body;\n const scrollY = window.scrollY;\n const prev = {\n position: body.style.position,\n top: body.style.top,\n left: body.style.left,\n right: body.style.right,\n overflow: body.style.overflow,\n };\n body.style.position = \"fixed\";\n body.style.top = `-${scrollY}px`;\n body.style.left = \"0\";\n body.style.right = \"0\";\n body.style.overflow = \"hidden\";\n\n const onKey = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onOpenChange(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n body.style.position = prev.position;\n body.style.top = prev.top;\n body.style.left = prev.left;\n body.style.right = prev.right;\n body.style.overflow = prev.overflow;\n window.scrollTo(0, scrollY);\n };\n }, [open, onOpenChange]);\n\n const onDragEnd = (_: unknown, info: PanInfo) => {\n const velocity = info.velocity.y;\n const offset = info.offset.y;\n\n // Strong downward fling or large drag → dismiss.\n if (velocity > 600 || offset > dismissThreshold) {\n const smaller = snapPoints.map((_, i) => i).filter((i) => i < snap);\n if (smaller.length && velocity < 800 && offset < dismissThreshold * 1.6) {\n setSnap(smaller[smaller.length - 1]);\n } else {\n onOpenChange(false);\n }\n return;\n }\n\n // Strong upward fling → next snap.\n if (velocity < -500) {\n setSnap((current) => Math.min(snapPoints.length - 1, current + 1));\n return;\n }\n\n // Otherwise snap to nearest by current offset.\n setSnap((current) => {\n if (offset > 80 && current > 0) return current - 1;\n if (offset < -80 && current < snapPoints.length - 1) return current + 1;\n return current;\n });\n };\n\n const snapValue = snapPoints[snap];\n const heightStyle =\n snapValue === \"auto\" ? { maxHeight: \"92vh\" } : { height: `${snapValue * 100}vh` };\n\n // Portal to <body>: an ancestor with backdrop-filter or transform becomes\n // the containing block for fixed descendants, which would position the\n // sheet against that ancestor instead of the viewport.\n if (!mounted) return null;\n\n return createPortal(\n <AnimatePresence>\n {open ? (\n <div className=\"pointer-events-none fixed inset-0 z-50\">\n <motion.button\n type=\"button\"\n aria-label=\"Close bottom sheet\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={DRAWER}\n onClick={() => onOpenChange(false)}\n // A dim scrim with a light blur. backdrop-blur is GPU-expensive and\n // re-rasterizes every frame the sheet drags over it; a small radius\n // plus more opacity keeps the glass look without the jank.\n className=\"pointer-events-auto absolute inset-0 bg-background/40 backdrop-blur-sm\"\n />\n <motion.div\n ref={sheetRef}\n drag=\"y\"\n dragControls={dragControls}\n dragListener={false}\n dragConstraints={{ top: 0, bottom: 0 }}\n dragElastic={{ top: 0.02, bottom: 0.4 }}\n dragMomentum={false}\n onDragEnd={onDragEnd}\n initial={reduce ? { y: 0, opacity: 0 } : { y: \"100%\" }}\n animate={reduce ? { y: 0, opacity: 1 } : { y: 0 }}\n exit={reduce ? { y: 0, opacity: 0 } : { y: \"100%\" }}\n transition={reduce ? { duration: 0.18, ease: EASE_DRAWER } : DRAWER}\n onAnimationComplete={() => {\n if (sheetRef.current) heightRef.current = sheetRef.current.offsetHeight;\n }}\n style={heightStyle}\n className={cn(\n \"pointer-events-auto absolute right-0 bottom-0 left-0 mx-auto flex max-w-2xl flex-col overflow-hidden rounded-t-3xl will-change-transform\",\n \"border border-border bg-background shadow-xl\",\n className,\n )}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={description ? descriptionId : undefined}\n aria-label={title ? undefined : \"Bottom sheet\"}\n >\n <div className=\"flex flex-col items-center px-4 pt-3 pb-2\">\n {/* Drag only the pill so the title and description stay selectable. */}\n <div\n onPointerDown={(event) => dragControls.start(event)}\n // A slow pull must not hand the gesture to iOS's callout,\n // which would leave the sheet frozen mid-drag.\n className={cn(\n \"flex cursor-grab touch-none items-center justify-center py-1 active:cursor-grabbing\",\n TOUCH_GESTURE_CONTENT_CLASS,\n )}\n >\n <div className=\"h-1.5 w-10 rounded-full bg-muted-foreground/40\" />\n </div>\n {title || description ? (\n <div className=\"mt-2 w-full\">\n {title ? (\n <h2 id={titleId} className=\"font-semibold text-base text-foreground\">\n {title}\n </h2>\n ) : null}\n {description ? (\n <p id={descriptionId} className=\"mt-0.5 text-muted-foreground text-sm\">\n {description}\n </p>\n ) : null}\n </div>\n ) : null}\n </div>\n {/* overscroll-contain stops boundary scrolls from chaining to the page. */}\n <div className=\"flex-1 overflow-y-auto overscroll-contain px-4 pb-6\">{children}</div>\n </motion.div>\n </div>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;AAmBA,MAAM,SAAS;CAAE,UAAU;CAAK,MAAM;AAAY;AAgBlD,SAAgB,YAAY,EAC1B,MACA,cACA,aAAa,CAAC,IAAK,GAAI,GACvB,cAAc,GACd,OACA,aACA,UACA,WACA,mBAAmB,OACA;CACnB,MAAM,CAAC,MAAM,WAAW,SAAS,WAAW;CAC5C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,eAAe,gBAAgB;CACrC,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,SAAS,iBAAiB;CAChC,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,MAAM,MAAM;CAClB,MAAM,UAAU,GAAG,IAAI;CACvB,MAAM,gBAAgB,GAAG,IAAI;CAE7B,gBAAgB;EACd,WAAW,IAAI;CACjB,GAAG,CAAC,CAAC;CAEL,gBAAgB;EACd,IAAI,MAAM,QAAQ,WAAW;CAC/B,GAAG,CAAC,MAAM,WAAW,CAAC;CAMtB,gBAAgB;EACd,IAAI,CAAC,MAAM;EACX,MAAM,OAAO,SAAS;EACtB,MAAM,UAAU,OAAO;EACvB,MAAM,OAAO;GACX,UAAU,KAAK,MAAM;GACrB,KAAK,KAAK,MAAM;GAChB,MAAM,KAAK,MAAM;GACjB,OAAO,KAAK,MAAM;GAClB,UAAU,KAAK,MAAM;EACvB;EACA,KAAK,MAAM,WAAW;EACtB,KAAK,MAAM,MAAM,IAAI,QAAQ;EAC7B,KAAK,MAAM,OAAO;EAClB,KAAK,MAAM,QAAQ;EACnB,KAAK,MAAM,WAAW;EAEtB,MAAM,SAAS,UAAyB;GACtC,IAAI,MAAM,QAAQ,UAAU;IAC1B,MAAM,eAAe;IACrB,aAAa,KAAK;GACpB;EACF;EACA,OAAO,iB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,WAAU;IAAuD;GAAc,CAAA,CAC1E;EACT,CAAA,CAAA;CACH,CAAA,IAAA,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
1
+ {"version":3,"file":"bottom-sheet.js","names":[],"sources":["../../../src/components/motion/bottom-sheet.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport {\n AnimatePresence,\n motion,\n type PanInfo,\n useDragControls,\n useReducedMotion,\n} from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_DRAWER } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\nimport { TOUCH_GESTURE_CONTENT_CLASS } from \"../../lib/touch\";\n\n// Vaul-style glide: a long, fully-damped tween reads smoother than a spring on\n// open — no settle/overshoot, just one clean decel. Same curve drives the\n// backdrop fade so the surface and scrim move as one.\nconst DRAWER = { duration: 0.5, ease: EASE_DRAWER } as const;\n\nexport interface BottomSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Heights (0-1 = fraction of viewport, or \"auto\"). First entry is default. */\n snapPoints?: (number | \"auto\")[];\n defaultSnap?: number;\n title?: string;\n description?: string;\n children?: ReactNode;\n className?: string;\n /** Min drag distance (px) past current snap to dismiss. */\n dismissThreshold?: number;\n}\n\nexport function BottomSheet({\n open,\n onOpenChange,\n snapPoints = [0.5, 0.92],\n defaultSnap = 0,\n title,\n description,\n children,\n className,\n dismissThreshold = 120,\n}: BottomSheetProps) {\n const [snap, setSnap] = useState(defaultSnap);\n const [mounted, setMounted] = useState(false);\n const dragControls = useDragControls();\n const sheetRef = useRef<HTMLDivElement>(null);\n const reduce = useReducedMotion();\n const heightRef = useRef(0);\n const uid = useId();\n const titleId = `${uid}-title`;\n const descriptionId = `${uid}-description`;\n\n useEffect(() => {\n setMounted(true);\n }, []);\n\n useEffect(() => {\n if (open) setSnap(defaultSnap);\n }, [open, defaultSnap]);\n\n // Lock background scroll while open. overflow:hidden alone is ignored by\n // iOS Safari — boundary scrolls inside the sheet chain to the page, which\n // scrolls underneath and ends up somewhere else on close. position:fixed\n // is the lock that actually holds; restore the scroll position after.\n useEffect(() => {\n if (!open) return;\n const body = document.body;\n const scrollY = window.scrollY;\n const prev = {\n position: body.style.position,\n top: body.style.top,\n left: body.style.left,\n right: body.style.right,\n overflow: body.style.overflow,\n };\n body.style.position = \"fixed\";\n body.style.top = `-${scrollY}px`;\n body.style.left = \"0\";\n body.style.right = \"0\";\n body.style.overflow = \"hidden\";\n\n const onKey = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onOpenChange(false);\n }\n };\n window.addEventListener(\"keydown\", onKey);\n\n return () => {\n window.removeEventListener(\"keydown\", onKey);\n body.style.position = prev.position;\n body.style.top = prev.top;\n body.style.left = prev.left;\n body.style.right = prev.right;\n body.style.overflow = prev.overflow;\n window.scrollTo(0, scrollY);\n };\n }, [open, onOpenChange]);\n\n const onDragEnd = (_: unknown, info: PanInfo) => {\n const velocity = info.velocity.y;\n const offset = info.offset.y;\n\n // Strong downward fling or large drag → dismiss.\n if (velocity > 600 || offset > dismissThreshold) {\n const smaller = snapPoints.map((_, i) => i).filter((i) => i < snap);\n if (smaller.length && velocity < 800 && offset < dismissThreshold * 1.6) {\n setSnap(smaller[smaller.length - 1]);\n } else {\n onOpenChange(false);\n }\n return;\n }\n\n // Strong upward fling → next snap.\n if (velocity < -500) {\n setSnap((current) => Math.min(snapPoints.length - 1, current + 1));\n return;\n }\n\n // Otherwise snap to nearest by current offset.\n setSnap((current) => {\n if (offset > 80 && current > 0) return current - 1;\n if (offset < -80 && current < snapPoints.length - 1) return current + 1;\n return current;\n });\n };\n\n const snapValue = snapPoints[snap];\n const heightStyle =\n snapValue === \"auto\" ? { maxHeight: \"92vh\" } : { height: `${snapValue * 100}vh` };\n\n // Portal to <body>: an ancestor with backdrop-filter or transform becomes\n // the containing block for fixed descendants, which would position the\n // sheet against that ancestor instead of the viewport.\n if (!mounted) return null;\n\n // Two fixed siblings, no wrapper: the scrim spans the viewport edges but\n // carries a colour, and the sheet is pinned to the bottom, stops short of the\n // top edge at every snap point the component ships, and paints an opaque\n // surface either way. Both hang off `PresenceGate`, so interaction releases in\n // the same commit that starts the exit rather than when it ends. See\n return createPortal(\n <AnimatePresence>\n {open ? (\n <PresenceGate key=\"backdrop\">\n {({ gate }) => (\n <motion.button\n type=\"button\"\n aria-label=\"Close bottom sheet\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n transition={DRAWER}\n {...gate}\n onClick={() => onOpenChange(false)}\n // A dim scrim with a light blur. backdrop-blur is GPU-expensive and\n // re-rasterizes every frame the sheet drags over it; a small radius\n // plus more opacity keeps the glass look without the jank.\n className=\"pointer-events-auto fixed inset-0 z-50 bg-background/40 backdrop-blur-sm\"\n />\n )}\n </PresenceGate>\n ) : null}\n {open ? (\n <PresenceGate key=\"sheet\">\n {({ gate }) => (\n <motion.div\n ref={sheetRef}\n drag=\"y\"\n dragControls={dragControls}\n dragListener={false}\n dragConstraints={{ top: 0, bottom: 0 }}\n dragElastic={{ top: 0.02, bottom: 0.4 }}\n dragMomentum={false}\n onDragEnd={onDragEnd}\n initial={reduce ? { y: 0, opacity: 0 } : { y: \"100%\" }}\n animate={reduce ? { y: 0, opacity: 1 } : { y: 0 }}\n exit={reduce ? { y: 0, opacity: 0 } : { y: \"100%\" }}\n transition={reduce ? { duration: 0.18, ease: EASE_DRAWER } : DRAWER}\n onAnimationComplete={() => {\n if (sheetRef.current) heightRef.current = sheetRef.current.offsetHeight;\n }}\n {...gate}\n style={{ ...heightStyle, ...gate.style }}\n className={cn(\n \"pointer-events-auto fixed right-0 bottom-0 left-0 z-50 mx-auto flex max-w-2xl flex-col overflow-hidden rounded-t-3xl will-change-transform\",\n \"border border-border bg-background shadow-xl\",\n className,\n )}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={description ? descriptionId : undefined}\n aria-label={title ? undefined : \"Bottom sheet\"}\n >\n <div className=\"flex flex-col items-center px-4 pt-3 pb-2\">\n {/* Drag only the pill so the title and description stay selectable. */}\n <div\n onPointerDown={(event) => dragControls.start(event)}\n // A slow pull must not hand the gesture to iOS's callout,\n // which would leave the sheet frozen mid-drag.\n className={cn(\n \"flex cursor-grab touch-none items-center justify-center py-1 active:cursor-grabbing\",\n TOUCH_GESTURE_CONTENT_CLASS,\n )}\n >\n <div className=\"h-1.5 w-10 rounded-full bg-muted-foreground/40\" />\n </div>\n {title || description ? (\n <div className=\"mt-2 w-full\">\n {title ? (\n <h2 id={titleId} className=\"font-semibold text-base text-foreground\">\n {title}\n </h2>\n ) : null}\n {description ? (\n <p id={descriptionId} className=\"mt-0.5 text-muted-foreground text-sm\">\n {description}\n </p>\n ) : null}\n </div>\n ) : null}\n </div>\n {/* overscroll-contain stops boundary scrolls from chaining to the page. */}\n <div className=\"flex-1 overflow-y-auto overscroll-contain px-4 pb-6\">{children}</div>\n </motion.div>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,SAAS;CAAE,UAAU;CAAK,MAAM;AAAY;AAgBlD,SAAgB,YAAY,EAC1B,MACA,cACA,aAAa,CAAC,IAAK,GAAI,GACvB,cAAc,GACd,OACA,aACA,UACA,WACA,mBAAmB,OACA;CACnB,MAAM,CAAC,MAAM,WAAW,SAAS,WAAW;CAC5C,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,eAAe,gBAAgB;CACrC,MAAM,WAAW,OAAuB,IAAI;CAC5C,MAAM,SAAS,iBAAiB;CAChC,MAAM,YAAY,OAAO,CAAC;CAC1B,MAAM,MAAM,MAAM;CAClB,MAAM,UAAU,GAAG,IAAI;CACvB,MAAM,gBAAgB,GAAG,IAAI;CAE7B,gBAAgB;EACd,WAAW,IAAI;CACjB,GAAG,CAAC,CAAC;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;EACA,GAAI;EACJ,OAAO;GAAE,GAAG;GAAa,GAAG,KAAK;EAAM;EACvC,WAAW,GACT,8IACA,gDACA,SACF;EACA,MAAK;EACL,cAAW;EACX,mBAAiB,QAAQ,UAAU,KAAA;EACnC,oBAAkB,cAAc,gBAAgB,KAAA;EAChD,cAAY,QAAQ,KAAA,IAAY;EA3BlC,UAAA,CA6BE,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CAEE,oBAAC,OAAD;IACE,gBAAgB,UAAU,aAAa,MAAM,KAAK;IAGlD,WAAW,GACT,uFACA,2BACF;IAEA,UAAA,oBAAC,OAAD,EAAK,WAAU,iDAAkD,CAAA;GAC9D,CAAA,GACJ,SAAS,cACR,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,QACC,oBAAC,MAAD;KAAI,IAAI;KAAS,WAAU;KACxB,UAAA;IACC,CAAA,IACF,MACH,cACC,oBAAC,KAAD;KAAG,IAAI;KAAe,WAAU;KAC7B,UAAA;IACA,CAAA,IACD,IACD;GACH,CAAA,IAAA,IACD;EAEL,CAAA,GAAA,oBAAC,OAAD;GAAK,WAAU;GAAuD;EAAc,CAAA,CAC1E;CAEF,CAAA,EAAA,GA/DI,OA+DJ,IACZ,IACW,EAAA,CAAA,GACjB,SAAS,IACX;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"center-morph-modal.d.ts","names":[],"sources":["../../../src/components/motion/center-morph-modal.tsx"],"mappings":";;UAwCiB;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;;;;;;iBAOF,mBACd,UACA,MAAM,gBACN,aACA,gBACC,wCAAqB,IAAA;UA6BP;EACf,UAAU;;;iBAII,0BAA0B,YAAY,+BAA4B,aAAA,kDAAA;UAqBjE;EACf,UAAU;;;iBAII,wBAAwB,YAAY,6BAA0B,aAAA,kDAAA;UAiB7D;EACf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;;iBAmCc,0BACd,UACA,WACA,iBACA,aACA,iBACA,kBACA,WACA,qBACC,+CAA4B"}
1
+ {"version":3,"file":"center-morph-modal.d.ts","names":[],"sources":["../../../src/components/motion/center-morph-modal.tsx"],"mappings":";;UAyCiB;EACf,UAAU;;EAEV;;EAEA;EACA,gBAAgB;;;;;;iBAOF,mBACd,UACA,MAAM,gBACN,aACA,gBACC,wCAAqB,IAAA;UA6BP;EACf,UAAU;;;iBAII,0BAA0B,YAAY,+BAA4B,aAAA,kDAAA;UAqBjE;EACf,UAAU;;;iBAII,wBAAwB,YAAY,6BAA0B,aAAA,kDAAA;UAiB7D;EACf,UAAU;;EAEV;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;;iBA+Bc,0BACd,UACA,WACA,iBACA,aACA,iBACA,kBACA,WACA,qBACC,+CAA4B"}
@@ -1,9 +1,10 @@
1
1
  "use client";
2
2
  import { EASE_OUT } from "../../lib/ease.js";
3
+ import { t as PresenceGate } from "../../presence-gate-BekdC4Bo.js";
3
4
  import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from "react";
4
5
  import { cn } from "@kumix/utils";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- import { AnimatePresence, motion, useIsPresent, useReducedMotion } from "motion/react";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ import { AnimatePresence, motion, useReducedMotion } from "motion/react";
7
8
  import { X } from "lucide-react";
8
9
  import { createPortal } from "react-dom";
9
10
  //#region src/components/motion/center-morph-modal.tsx
@@ -92,14 +93,10 @@ function getFocusableElements(root) {
92
93
  if (!root) return [];
93
94
  return Array.from(root.querySelectorAll(FOCUSABLE_SELECTOR)).filter((element) => element.tabIndex >= 0);
94
95
  }
95
- function PresencePointerGate({ children }) {
96
- return children(useIsPresent());
97
- }
98
96
  function CenterMorphModalContent({ children, ariaLabel, ariaDescribedBy, dismissible = true, showCloseButton = true, closeButtonLabel = "Close modal", className, backdropClassName }) {
99
97
  const context = useCenterMorphModalContext("CenterMorphModalContent");
100
98
  const reduce = useReducedMotion() ?? false;
101
99
  const [mounted, setMounted] = useState(false);
102
- const overlayRef = useRef(null);
103
100
  const panelRef = useRef(null);
104
101
  useEffect(() => setMounted(true), []);
105
102
  useEffect(() => {
@@ -107,7 +104,7 @@ function CenterMorphModalContent({ children, ariaLabel, ariaDescribedBy, dismiss
107
104
  const previousOverflow = document.body.style.overflow;
108
105
  document.body.style.overflow = "hidden";
109
106
  const focusFrame = requestAnimationFrame(() => {
110
- const [firstFocusable] = getFocusableElements(overlayRef.current);
107
+ const [firstFocusable] = getFocusableElements(panelRef.current);
111
108
  (firstFocusable ?? panelRef.current)?.focus();
112
109
  });
113
110
  const onKeyDown = (event) => {
@@ -117,7 +114,7 @@ function CenterMorphModalContent({ children, ariaLabel, ariaDescribedBy, dismiss
117
114
  return;
118
115
  }
119
116
  if (event.key !== "Tab") return;
120
- const focusable = getFocusableElements(overlayRef.current);
117
+ const focusable = getFocusableElements(panelRef.current);
121
118
  if (focusable.length === 0) {
122
119
  event.preventDefault();
123
120
  panelRef.current?.focus();
@@ -142,95 +139,92 @@ function CenterMorphModalContent({ children, ariaLabel, ariaDescribedBy, dismiss
142
139
  };
143
140
  }, [context, dismissible]);
144
141
  if (!mounted) return null;
145
- return createPortal(/* @__PURE__ */ jsx(AnimatePresence, { children: context.open ? /* @__PURE__ */ jsx(PresencePointerGate, { children: (isPresent) => /* @__PURE__ */ jsxs("div", {
146
- ref: overlayRef,
147
- className: "pointer-events-none fixed inset-0 z-100",
148
- children: [/* @__PURE__ */ jsx(motion.button, {
149
- type: "button",
150
- "aria-label": "Dismiss modal",
151
- tabIndex: -1,
152
- disabled: !dismissible,
153
- initial: { opacity: 0 },
154
- animate: { opacity: 1 },
155
- exit: { opacity: 0 },
156
- style: { pointerEvents: isPresent ? "auto" : "none" },
157
- transition: {
158
- duration: reduce ? .1 : .28,
159
- ease: EASE_OUT
160
- },
161
- onClick: () => context.setOpen(false),
162
- className: cn("pointer-events-auto absolute inset-0 h-full w-full cursor-default bg-background/10 backdrop-blur-sm", backdropClassName)
163
- }), /* @__PURE__ */ jsx("div", {
164
- className: "pointer-events-none absolute inset-0 flex items-center justify-center overflow-y-auto p-4 drop-shadow-2xl",
165
- children: /* @__PURE__ */ jsx("div", {
166
- className: "flex w-full flex-col items-center py-8",
167
- children: /* @__PURE__ */ jsxs(motion.div, {
168
- ref: panelRef,
169
- id: context.contentId,
170
- role: "dialog",
171
- "aria-modal": "true",
172
- "aria-label": ariaLabel,
173
- "aria-describedby": ariaDescribedBy,
174
- tabIndex: -1,
175
- initial: reduce ? {
142
+ return createPortal(/* @__PURE__ */ jsx(AnimatePresence, { children: context.open ? /* @__PURE__ */ jsx(PresenceGate, { children: ({ isPresent, gate }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(motion.button, {
143
+ type: "button",
144
+ "aria-label": "Dismiss modal",
145
+ tabIndex: -1,
146
+ disabled: !dismissible,
147
+ initial: { opacity: 0 },
148
+ animate: { opacity: 1 },
149
+ exit: { opacity: 0 },
150
+ ...gate,
151
+ transition: {
152
+ duration: reduce ? .1 : .28,
153
+ ease: EASE_OUT
154
+ },
155
+ onClick: () => context.setOpen(false),
156
+ className: cn("pointer-events-auto fixed inset-0 z-100 h-full w-full cursor-default bg-background/10 backdrop-blur-sm", backdropClassName)
157
+ }), /* @__PURE__ */ jsx("div", {
158
+ inert: !isPresent,
159
+ className: "pointer-events-none fixed inset-4 z-100 flex items-center justify-center overflow-y-auto drop-shadow-2xl",
160
+ children: /* @__PURE__ */ jsx("div", {
161
+ className: "flex w-full flex-col items-center py-8",
162
+ children: /* @__PURE__ */ jsxs(motion.div, {
163
+ ref: panelRef,
164
+ id: context.contentId,
165
+ role: "dialog",
166
+ "aria-modal": "true",
167
+ "aria-label": ariaLabel,
168
+ "aria-describedby": ariaDescribedBy,
169
+ tabIndex: -1,
170
+ initial: reduce ? {
171
+ opacity: 0,
172
+ clipPath: CENTER_OPEN_CLIP
173
+ } : {
174
+ opacity: 1,
175
+ clipPath: CENTER_FOLDED_CLIP
176
+ },
177
+ animate: {
178
+ opacity: 1,
179
+ clipPath: CENTER_OPEN_CLIP
180
+ },
181
+ exit: reduce ? {
182
+ opacity: 0,
183
+ clipPath: CENTER_OPEN_CLIP
184
+ } : {
185
+ opacity: 1,
186
+ clipPath: CENTER_FOLDED_CLIP
187
+ },
188
+ ...gate,
189
+ transition: reduce ? {
190
+ duration: .14,
191
+ ease: EASE_OUT
192
+ } : CENTER_UNFOLD_TRANSITION,
193
+ className: cn("pointer-events-auto relative w-full max-w-[26rem] origin-center overflow-hidden rounded-[30px] border border-border bg-background will-change-[clip-path]", className),
194
+ children: [children, showCloseButton ? /* @__PURE__ */ jsx(motion.button, {
195
+ type: "button",
196
+ "aria-label": closeButtonLabel,
197
+ onClick: () => context.setOpen(false),
198
+ initial: reduce ? { opacity: 0 } : {
176
199
  opacity: 0,
177
- clipPath: CENTER_OPEN_CLIP
178
- } : {
179
- opacity: 1,
180
- clipPath: CENTER_FOLDED_CLIP
200
+ scale: .8
181
201
  },
182
202
  animate: {
183
203
  opacity: 1,
184
- clipPath: CENTER_OPEN_CLIP
204
+ scale: 1
185
205
  },
186
- exit: reduce ? {
206
+ exit: {
187
207
  opacity: 0,
188
- clipPath: CENTER_OPEN_CLIP
189
- } : {
190
- opacity: 1,
191
- clipPath: CENTER_FOLDED_CLIP
192
- },
193
- style: { pointerEvents: isPresent ? "auto" : "none" },
194
- transition: reduce ? {
195
- duration: .14,
196
- ease: EASE_OUT
197
- } : CENTER_UNFOLD_TRANSITION,
198
- className: cn("pointer-events-auto relative w-full max-w-[26rem] origin-center overflow-hidden rounded-[30px] border border-border bg-background will-change-[clip-path]", className),
199
- children: [children, showCloseButton ? /* @__PURE__ */ jsx(motion.button, {
200
- type: "button",
201
- "aria-label": closeButtonLabel,
202
- onClick: () => context.setOpen(false),
203
- initial: reduce ? { opacity: 0 } : {
204
- opacity: 0,
205
- scale: .8
206
- },
207
- animate: {
208
- opacity: 1,
209
- scale: 1
210
- },
211
- exit: {
212
- opacity: 0,
213
- scale: reduce ? 1 : .88,
214
- transition: {
215
- duration: .1,
216
- ease: EASE_OUT
217
- }
218
- },
208
+ scale: reduce ? 1 : .88,
219
209
  transition: {
220
- delay: reduce ? 0 : .16,
221
- duration: reduce ? .12 : .2,
210
+ duration: .1,
222
211
  ease: EASE_OUT
223
- },
224
- className: "absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-full bg-foreground/5 text-muted-foreground transition-colors hover:bg-foreground/8 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
225
- children: /* @__PURE__ */ jsx(X, {
226
- className: "h-4 w-4",
227
- "aria-hidden": "true"
228
- })
229
- }) : null]
230
- })
212
+ }
213
+ },
214
+ transition: {
215
+ delay: reduce ? 0 : .16,
216
+ duration: reduce ? .12 : .2,
217
+ ease: EASE_OUT
218
+ },
219
+ className: "absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-full bg-foreground/5 text-muted-foreground transition-colors hover:bg-foreground/8 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
220
+ children: /* @__PURE__ */ jsx(X, {
221
+ className: "h-4 w-4",
222
+ "aria-hidden": "true"
223
+ })
224
+ }) : null]
231
225
  })
232
- })]
233
- }) }) : null }), document.body);
226
+ })
227
+ })] }) }) : null }), document.body);
234
228
  }
235
229
  //#endregion
236
230
  export { CenterMorphModal, CenterMorphModalClose, CenterMorphModalContent, CenterMorphModalTrigger };
@@ -1 +1 @@
1
- {"version":3,"file":"center-morph-modal.js","names":[],"sources":["../../../src/components/motion/center-morph-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { X } from \"lucide-react\";\nimport { AnimatePresence, motion, useIsPresent, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\n\ntype CenterMorphModalContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n triggerId: string;\n contentId: string;\n};\n\nconst CenterMorphModalContext = createContext<CenterMorphModalContextValue | null>(null);\n\nfunction useCenterMorphModalContext(component: string) {\n const context = useContext(CenterMorphModalContext);\n if (!context) {\n throw new Error(`${component} must be used within <CenterMorphModal>`);\n }\n return context;\n}\n\nexport interface CenterMorphModalProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Initial state when used uncontrolled. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\n/**\n * A modal whose full-size surface unfolds outward from its exact center.\n * Supports controlled and uncontrolled state through composable primitives.\n */\nexport function CenterMorphModal({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n}: CenterMorphModalProps) {\n const id = useId();\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 value = useMemo<CenterMorphModalContextValue>(\n () => ({\n open,\n setOpen,\n triggerId: `${id}-trigger`,\n contentId: `${id}-content`,\n }),\n [id, open, setOpen],\n );\n\n return (\n <CenterMorphModalContext.Provider value={value}>{children}</CenterMorphModalContext.Provider>\n );\n}\n\nexport interface CenterMorphModalTriggerProps {\n children: ReactElement;\n}\n\n/** Wraps one interactive element and opens or closes the modal. */\nexport function CenterMorphModalTrigger({ children }: CenterMorphModalTriggerProps) {\n const context = useCenterMorphModalContext(\"CenterMorphModalTrigger\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as\n | ((event: React.MouseEvent<HTMLElement>) => void)\n | undefined;\n\n return cloneElement(child, {\n id: context.triggerId,\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n childOnClick?.(event);\n if (!event.defaultPrevented) context.setOpen(!context.open);\n },\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": context.open,\n \"aria-controls\": context.open ? context.contentId : undefined,\n });\n}\n\nexport interface CenterMorphModalCloseProps {\n children: ReactElement;\n}\n\n/** Wraps one interactive element and closes the modal. */\nexport function CenterMorphModalClose({ children }: CenterMorphModalCloseProps) {\n const context = useCenterMorphModalContext(\"CenterMorphModalClose\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as\n | ((event: React.MouseEvent<HTMLElement>) => void)\n | undefined;\n\n return cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n childOnClick?.(event);\n if (!event.defaultPrevented) context.setOpen(false);\n },\n });\n}\n\nexport interface CenterMorphModalContentProps {\n children: ReactNode;\n /** Accessible name announced by screen readers. */\n ariaLabel: string;\n /** Optional id of descriptive content inside the modal. */\n ariaDescribedBy?: string;\n /** Close on Escape or backdrop press. Default true. */\n dismissible?: boolean;\n /** Render the close control inside the panel's top-right corner. Default true. */\n showCloseButton?: boolean;\n closeButtonLabel?: string;\n className?: string;\n backdropClassName?: string;\n}\n\nconst FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(\",\");\n\nconst CENTER_FOLDED_CLIP = \"inset(48% 48% 48% 48% round 30px)\";\nconst CENTER_OPEN_CLIP = \"inset(0% 0% 0% 0% round 30px)\";\n\n// Complex clip-path strings can snap when a spring resolves its final distance.\n// Keep the radius constant so the whole duration reads as surface unfolding,\n// rather than finishing early and spending its last frames rounding corners.\nconst CENTER_UNFOLD_EASE = [0.2, 0, 0.2, 1] as const;\nconst CENTER_UNFOLD_TRANSITION = {\n duration: 0.43,\n ease: CENTER_UNFOLD_EASE,\n} as const;\n\nfunction getFocusableElements(root: HTMLElement | null) {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(\n (element) => element.tabIndex >= 0,\n );\n}\n\nfunction PresencePointerGate({ children }: { children: (isPresent: boolean) => ReactNode }) {\n return children(useIsPresent());\n}\n\nexport function CenterMorphModalContent({\n children,\n ariaLabel,\n ariaDescribedBy,\n dismissible = true,\n showCloseButton = true,\n closeButtonLabel = \"Close modal\",\n className,\n backdropClassName,\n}: CenterMorphModalContentProps) {\n const context = useCenterMorphModalContext(\"CenterMorphModalContent\");\n const reduce = useReducedMotion() ?? false;\n const [mounted, setMounted] = useState(false);\n const overlayRef = useRef<HTMLDivElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (!context.open) return;\n\n const previousOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n\n const focusFrame = requestAnimationFrame(() => {\n const [firstFocusable] = getFocusableElements(overlayRef.current);\n (firstFocusable ?? panelRef.current)?.focus();\n });\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\" && dismissible) {\n event.preventDefault();\n context.setOpen(false);\n return;\n }\n\n if (event.key !== \"Tab\") return;\n const focusable = getFocusableElements(overlayRef.current);\n if (focusable.length === 0) {\n event.preventDefault();\n panelRef.current?.focus();\n return;\n }\n\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n window.addEventListener(\"keydown\", onKeyDown);\n return () => {\n cancelAnimationFrame(focusFrame);\n window.removeEventListener(\"keydown\", onKeyDown);\n document.body.style.overflow = previousOverflow;\n document.getElementById(context.triggerId)?.focus();\n };\n }, [context, dismissible]);\n\n if (!mounted) return null;\n\n return createPortal(\n <AnimatePresence>\n {context.open ? (\n <PresencePointerGate>\n {(isPresent) => (\n <div ref={overlayRef} className=\"pointer-events-none fixed inset-0 z-100\">\n <motion.button\n type=\"button\"\n aria-label=\"Dismiss modal\"\n tabIndex={-1}\n disabled={!dismissible}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n style={{ pointerEvents: isPresent ? \"auto\" : \"none\" }}\n transition={{\n duration: reduce ? 0.1 : 0.28,\n ease: EASE_OUT,\n }}\n onClick={() => context.setOpen(false)}\n className={cn(\n \"pointer-events-auto absolute inset-0 h-full w-full cursor-default bg-background/10 backdrop-blur-sm\",\n backdropClassName,\n )}\n />\n\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center overflow-y-auto p-4 drop-shadow-2xl\">\n {/* Drop-shadow reads the clipped child's alpha, so depth follows the\n unfolding silhouette without introducing another panel layer. */}\n <div className=\"flex w-full flex-col items-center py-8\">\n <motion.div\n ref={panelRef}\n id={context.contentId}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n tabIndex={-1}\n initial={\n reduce\n ? { opacity: 0, clipPath: CENTER_OPEN_CLIP }\n : { opacity: 1, clipPath: CENTER_FOLDED_CLIP }\n }\n animate={{\n opacity: 1,\n clipPath: CENTER_OPEN_CLIP,\n }}\n exit={\n reduce\n ? {\n opacity: 0,\n clipPath: CENTER_OPEN_CLIP,\n }\n : {\n opacity: 1,\n clipPath: CENTER_FOLDED_CLIP,\n }\n }\n style={{ pointerEvents: isPresent ? \"auto\" : \"none\" }}\n transition={\n reduce ? { duration: 0.14, ease: EASE_OUT } : CENTER_UNFOLD_TRANSITION\n }\n className={cn(\n \"pointer-events-auto relative w-full max-w-[26rem] origin-center overflow-hidden rounded-[30px] border border-border bg-background will-change-[clip-path]\",\n className,\n )}\n >\n {children}\n\n {showCloseButton ? (\n <motion.button\n type=\"button\"\n aria-label={closeButtonLabel}\n onClick={() => context.setOpen(false)}\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.8 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{\n opacity: 0,\n scale: reduce ? 1 : 0.88,\n transition: { duration: 0.1, ease: EASE_OUT },\n }}\n transition={{\n delay: reduce ? 0 : 0.16,\n duration: reduce ? 0.12 : 0.2,\n ease: EASE_OUT,\n }}\n className=\"absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-full bg-foreground/5 text-muted-foreground transition-colors hover:bg-foreground/8 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </motion.button>\n ) : null}\n </motion.div>\n </div>\n </div>\n </div>\n )}\n </PresencePointerGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;AA8BA,MAAM,0BAA0B,cAAmD,IAAI;AAEvF,SAAS,2BAA2B,WAAmB;CACrD,MAAM,UAAU,WAAW,uBAAuB;CAClD,IAAI,CAAC,SACH,MAAM,IAAI,MAAM,GAAG,UAAU,wCAAwC;CAEvE,OAAO;AACT;;;;;AAeA,SAAgB,iBAAiB,EAC/B,UACA,MAAM,gBACN,cAAc,OACd,gBACwB;CACxB,MAAM,KAAK,MAAM;CACjB,MAAM,CAAC,cAAc,mBAAmB,SAAS,WAAW;CAC5D,MAAM,aAAa,mBAAmB,KAAA;CACtC,MAAM,OAAO,aAAa,iBAAiB;CAE3C,MAAM,UAAU,aACb,SAAkB;EACjB,IAAI,CAAC,YAAY,gBAAgB,IAAI;EACrC,eAAe,IAAI;CACrB,GACA,CAAC,YAAY,YAAY,CAC3B;CAEA,MAAM,QAAQ,eACL;EACL;EACA;EACA,WAAW,GAAG,GAAG;EACjB,WAAW,GAAG,GAAG;CACnB,IACA;EAAC;EAAI;EAAM;CAAO,CACpB;CAEA,OACE,oBAAC,wBAAwB,UAAzB;EAAyC;EAAQ;CA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G,OAAO;MAAE;MAChC,MAAM;OACJ,SAAS;OACT,OAAO,SAAS,IAAI;OACpB,YAAY;QAAE,UAAU;QAAK,MAAM;OAAS;MAC9C;MACA,YAAY;OACV,OAAO,SAAS,IAAI;OACpB,UAAU,SAAS,MAAO;OAC1B,MAAM;MACR;MACA,WAAU;MAEV,UAAA,oBAAC,GAAD;OAAG,WAAU;OAAU,eAAY;MAAQ,CAAA;KAC9B,CAAA,IACb,IACM;;GACT,CAAA;EACF,CAAA,CACF;CAEY,CAAA,EAAA,CAAA,IACnB,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
1
+ {"version":3,"file":"center-morph-modal.js","names":[],"sources":["../../../src/components/motion/center-morph-modal.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n cloneElement,\n createContext,\n isValidElement,\n type ReactElement,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { X } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { createPortal } from \"react-dom\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { PresenceGate } from \"../../lib/presence-gate\";\n\ntype CenterMorphModalContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n triggerId: string;\n contentId: string;\n};\n\nconst CenterMorphModalContext = createContext<CenterMorphModalContextValue | null>(null);\n\nfunction useCenterMorphModalContext(component: string) {\n const context = useContext(CenterMorphModalContext);\n if (!context) {\n throw new Error(`${component} must be used within <CenterMorphModal>`);\n }\n return context;\n}\n\nexport interface CenterMorphModalProps {\n children: ReactNode;\n /** Controlled open state. */\n open?: boolean;\n /** Initial state when used uncontrolled. */\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n}\n\n/**\n * A modal whose full-size surface unfolds outward from its exact center.\n * Supports controlled and uncontrolled state through composable primitives.\n */\nexport function CenterMorphModal({\n children,\n open: controlledOpen,\n defaultOpen = false,\n onOpenChange,\n}: CenterMorphModalProps) {\n const id = useId();\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 value = useMemo<CenterMorphModalContextValue>(\n () => ({\n open,\n setOpen,\n triggerId: `${id}-trigger`,\n contentId: `${id}-content`,\n }),\n [id, open, setOpen],\n );\n\n return (\n <CenterMorphModalContext.Provider value={value}>{children}</CenterMorphModalContext.Provider>\n );\n}\n\nexport interface CenterMorphModalTriggerProps {\n children: ReactElement;\n}\n\n/** Wraps one interactive element and opens or closes the modal. */\nexport function CenterMorphModalTrigger({ children }: CenterMorphModalTriggerProps) {\n const context = useCenterMorphModalContext(\"CenterMorphModalTrigger\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as\n | ((event: React.MouseEvent<HTMLElement>) => void)\n | undefined;\n\n return cloneElement(child, {\n id: context.triggerId,\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n childOnClick?.(event);\n if (!event.defaultPrevented) context.setOpen(!context.open);\n },\n \"aria-haspopup\": \"dialog\",\n \"aria-expanded\": context.open,\n \"aria-controls\": context.open ? context.contentId : undefined,\n });\n}\n\nexport interface CenterMorphModalCloseProps {\n children: ReactElement;\n}\n\n/** Wraps one interactive element and closes the modal. */\nexport function CenterMorphModalClose({ children }: CenterMorphModalCloseProps) {\n const context = useCenterMorphModalContext(\"CenterMorphModalClose\");\n if (!isValidElement(children)) return children;\n\n const child = children as ReactElement<Record<string, unknown>>;\n const childOnClick = child.props.onClick as\n | ((event: React.MouseEvent<HTMLElement>) => void)\n | undefined;\n\n return cloneElement(child, {\n onClick: (event: React.MouseEvent<HTMLElement>) => {\n childOnClick?.(event);\n if (!event.defaultPrevented) context.setOpen(false);\n },\n });\n}\n\nexport interface CenterMorphModalContentProps {\n children: ReactNode;\n /** Accessible name announced by screen readers. */\n ariaLabel: string;\n /** Optional id of descriptive content inside the modal. */\n ariaDescribedBy?: string;\n /** Close on Escape or backdrop press. Default true. */\n dismissible?: boolean;\n /** Render the close control inside the panel's top-right corner. Default true. */\n showCloseButton?: boolean;\n closeButtonLabel?: string;\n className?: string;\n backdropClassName?: string;\n}\n\nconst FOCUSABLE_SELECTOR = [\n \"a[href]\",\n \"button:not([disabled])\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n '[tabindex]:not([tabindex=\"-1\"])',\n].join(\",\");\n\nconst CENTER_FOLDED_CLIP = \"inset(48% 48% 48% 48% round 30px)\";\nconst CENTER_OPEN_CLIP = \"inset(0% 0% 0% 0% round 30px)\";\n\n// Complex clip-path strings can snap when a spring resolves its final distance.\n// Keep the radius constant so the whole duration reads as surface unfolding,\n// rather than finishing early and spending its last frames rounding corners.\nconst CENTER_UNFOLD_EASE = [0.2, 0, 0.2, 1] as const;\nconst CENTER_UNFOLD_TRANSITION = {\n duration: 0.43,\n ease: CENTER_UNFOLD_EASE,\n} as const;\n\nfunction getFocusableElements(root: HTMLElement | null) {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(\n (element) => element.tabIndex >= 0,\n );\n}\n\nexport function CenterMorphModalContent({\n children,\n ariaLabel,\n ariaDescribedBy,\n dismissible = true,\n showCloseButton = true,\n closeButtonLabel = \"Close modal\",\n className,\n backdropClassName,\n}: CenterMorphModalContentProps) {\n const context = useCenterMorphModalContext(\"CenterMorphModalContent\");\n const reduce = useReducedMotion() ?? false;\n const [mounted, setMounted] = useState(false);\n const panelRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => setMounted(true), []);\n\n useEffect(() => {\n if (!context.open) return;\n\n const previousOverflow = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n\n const focusFrame = requestAnimationFrame(() => {\n const [firstFocusable] = getFocusableElements(panelRef.current);\n (firstFocusable ?? panelRef.current)?.focus();\n });\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\" && dismissible) {\n event.preventDefault();\n context.setOpen(false);\n return;\n }\n\n if (event.key !== \"Tab\") return;\n const focusable = getFocusableElements(panelRef.current);\n if (focusable.length === 0) {\n event.preventDefault();\n panelRef.current?.focus();\n return;\n }\n\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n\n window.addEventListener(\"keydown\", onKeyDown);\n return () => {\n cancelAnimationFrame(focusFrame);\n window.removeEventListener(\"keydown\", onKeyDown);\n document.body.style.overflow = previousOverflow;\n document.getElementById(context.triggerId)?.focus();\n };\n }, [context, dismissible]);\n\n if (!mounted) return null;\n\n return createPortal(\n <AnimatePresence>\n {context.open ? (\n <PresenceGate>\n {({ isPresent, gate }) => (\n <>\n <motion.button\n type=\"button\"\n aria-label=\"Dismiss modal\"\n tabIndex={-1}\n disabled={!dismissible}\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0 }}\n {...gate}\n transition={{\n duration: reduce ? 0.1 : 0.28,\n ease: EASE_OUT,\n }}\n onClick={() => context.setOpen(false)}\n className={cn(\n \"pointer-events-auto fixed inset-0 z-100 h-full w-full cursor-default bg-background/10 backdrop-blur-sm\",\n backdropClassName,\n )}\n />\n\n {/* `inset-4` rather than `inset-0 p-4`: same content box, but the\n layer stays off the viewport edges. It never takes pointer\n events, so it carries `inert` alone. */}\n <div\n inert={!isPresent}\n className=\"pointer-events-none fixed inset-4 z-100 flex items-center justify-center overflow-y-auto drop-shadow-2xl\"\n >\n {/* Drop-shadow reads the clipped child's alpha, so depth follows the\n unfolding silhouette without introducing another panel layer. */}\n <div className=\"flex w-full flex-col items-center py-8\">\n <motion.div\n ref={panelRef}\n id={context.contentId}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={ariaLabel}\n aria-describedby={ariaDescribedBy}\n tabIndex={-1}\n initial={\n reduce\n ? { opacity: 0, clipPath: CENTER_OPEN_CLIP }\n : { opacity: 1, clipPath: CENTER_FOLDED_CLIP }\n }\n animate={{\n opacity: 1,\n clipPath: CENTER_OPEN_CLIP,\n }}\n exit={\n reduce\n ? {\n opacity: 0,\n clipPath: CENTER_OPEN_CLIP,\n }\n : {\n opacity: 1,\n clipPath: CENTER_FOLDED_CLIP,\n }\n }\n {...gate}\n transition={\n reduce ? { duration: 0.14, ease: EASE_OUT } : CENTER_UNFOLD_TRANSITION\n }\n className={cn(\n \"pointer-events-auto relative w-full max-w-[26rem] origin-center overflow-hidden rounded-[30px] border border-border bg-background will-change-[clip-path]\",\n className,\n )}\n >\n {children}\n\n {showCloseButton ? (\n <motion.button\n type=\"button\"\n aria-label={closeButtonLabel}\n onClick={() => context.setOpen(false)}\n initial={reduce ? { opacity: 0 } : { opacity: 0, scale: 0.8 }}\n animate={{ opacity: 1, scale: 1 }}\n exit={{\n opacity: 0,\n scale: reduce ? 1 : 0.88,\n transition: { duration: 0.1, ease: EASE_OUT },\n }}\n transition={{\n delay: reduce ? 0 : 0.16,\n duration: reduce ? 0.12 : 0.2,\n ease: EASE_OUT,\n }}\n className=\"absolute top-4 right-4 inline-flex h-8 w-8 items-center justify-center rounded-full bg-foreground/5 text-muted-foreground transition-colors hover:bg-foreground/8 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </motion.button>\n ) : null}\n </motion.div>\n </div>\n </div>\n </>\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>,\n document.body,\n );\n}\n"],"mappings":";;;;;;;;;;AA+BA,MAAM,0BAA0B,cAAmD,IAAI;AAEvF,SAAS,2BAA2B,WAAmB;CACrD,MAAM,UAAU,WAAW,uBAAuB;CAClD,IAAI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AAS;KACP,SAAS;KACT,UAAU;IACZ;IACA,MACE,SACI;KACE,SAAS;KACT,UAAU;IACZ,IACA;KACE,SAAS;KACT,UAAU;IACZ;IAEN,GAAI;IACJ,YACE,SAAS;KAAE,UAAU;KAAM,MAAM;IAAS,IAAI;IAEhD,WAAW,GACT,6JACA,SACF;IAnCF,UAAA,CAqCG,UAEA,kBACC,oBAAC,OAAO,QAAR;KACE,MAAK;KACL,cAAY;KACZ,eAAe,QAAQ,QAAQ,KAAK;KACpC,SAAS,SAAS,EAAE,SAAS,EAAE,IAAI;MAAE,SAAS;MAAG,OAAO;KAAI;KAC5D,SAAS;MAAE,SAAS;MAAG,OAAO;KAAE;KAChC,MAAM;MACJ,SAAS;MACT,OAAO,SAAS,IAAI;MACpB,YAAY;OAAE,UAAU;OAAK,MAAM;MAAS;KAC9C;KACA,YAAY;MACV,OAAO,SAAS,IAAI;MACpB,UAAU,SAAS,MAAO;MAC1B,MAAM;KACR;KACA,WAAU;KAEV,UAAA,oBAAC,GAAD;MAAG,WAAU;MAAU,eAAY;KAAQ,CAAA;IAC9B,CAAA,IACb,IACM;;EACT,CAAA;CACF,CAAA,CACL,EAAA,CAAA,EAEQ,CAAA,IACZ,KACW,CAAA,GACjB,SAAS,IACX;AACF"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { t as usePopoverPortalPosition } from "../../../popover-position-BUqYCq8X.js";
3
- import { useComboboxContext } from "./context.js";
3
+ import { a as useComboboxContext } from "../../../context-BizvUNZv.js";
4
4
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
5
5
  import { cn } from "@kumix/utils";
6
6
  import { jsx } from "react/jsx-runtime";
@@ -17,7 +17,13 @@ type ComboboxContextValue = {
17
17
  select: (value: string) => void;
18
18
  query: string;
19
19
  setQuery: (query: string) => void;
20
+ /** The option the list is currently pointing at, resolved during render. */
20
21
  activeValue: string | null;
22
+ /**
23
+ * Records where the pointer or keyboard moved to. The recorded value is
24
+ * dropped when the query or the result set changes, so it does not always
25
+ * survive to the next `activeValue`.
26
+ */
21
27
  setActiveValue: (value: string | null) => void;
22
28
  moveActive: (direction: 1 | -1 | "first" | "last") => void;
23
29
  selectActive: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","names":[],"sources":["../../../../src/components/motion/combobox/context.tsx"],"mappings":";;KAmBY;EACV;EACA;EACA;EACA;EACA;EACA;EACA,KAAK,iBAAiB;;KAGZ,kBAAkB,eAAe,eAAe;KAehD;EACV;EACA,UAAU,eAAe;EACzB;EACA,SAAS;EACT;EACA,WAAW;EACX;EACA,iBAAiB;EACjB,aAAa;EACb;EACA,eAAe,MAAM;EACrB,iBAAiB;EACjB,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY,iBAAiB;EAC7B,YAAY,iBAAiB;EAC7B,UAAU,iBAAiB;EAC3B;;cAGW,iCAAe,QAAA;cACf,sCAAoB;iBAEjB,mBAAmB,oBAAiB;iBAMpC,UAAU,MAAM,MAAM,MAAM,IAAI,mBACtC,MAAM;UAQC;EACf,UAAU;EACV;EACA;EACA,iBAAiB;EACjB;EACA;EACA,gBAAgB;EAChB;EACA;EACA,iBAAiB;EACjB,SAAS;EACT;EACA;;iBAGc,WACd,UACA,OAAO,iBACP,cACA,eACA,MAAM,gBACN,aACA,cACA,OAAO,iBACP,cACA,eACA,QACA,UACA,aACC,gCAAa,IAAA"}
1
+ {"version":3,"file":"context.d.ts","names":[],"sources":["../../../../src/components/motion/combobox/context.tsx"],"mappings":";;KAoBY;EACV;EACA;EACA;EACA;EACA;EACA;EACA,KAAK,iBAAiB;;KAGZ,kBAAkB,eAAe,eAAe;KAehD;EACV;EACA,UAAU,eAAe;EACzB;EACA,SAAS;EACT;EACA,WAAW;;EAEX;;;;;;EAMA,iBAAiB;EACjB,aAAa;EACb;EACA,eAAe,MAAM;EACrB,iBAAiB;EACjB,WAAW;EACX,YAAY;EACZ,kBAAkB;EAClB;EACA;EACA;EACA;EACA;EACA;EACA;EACA,YAAY,iBAAiB;EAC7B,YAAY,iBAAiB;EAC7B,UAAU,iBAAiB;EAC3B;;cAGW,iCAAe,QAAA;cACf,sCAAoB;iBAEjB,mBAAmB,oBAAiB;iBAMpC,UAAU,MAAM,MAAM,MAAM,IAAI,mBACtC,MAAM;UAQC;EACf,UAAU;EACV;EACA;EACA,iBAAiB;EACjB;EACA;EACA,gBAAgB;EAChB;EACA;EACA,iBAAiB;EACjB,SAAS;EACT;EACA;;iBAGc,WACd,UACA,OAAO,iBACP,cACA,eACA,MAAM,gBACN,aACA,cACA,OAAO,iBACP,cACA,eACA,QACA,UACA,aACC,gCAAa,IAAA"}