@refraction-ui/react 0.19.1 → 0.20.0

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 (342) hide show
  1. package/dist/chunk-533MCMSU.js +2355 -0
  2. package/dist/chunk-533MCMSU.js.map +7 -0
  3. package/dist/chunk-AMK4VCBG.js +250 -0
  4. package/dist/chunk-AMK4VCBG.js.map +7 -0
  5. package/dist/chunk-BOLFYVI6.js +90 -0
  6. package/dist/chunk-BOLFYVI6.js.map +7 -0
  7. package/dist/chunk-F7B64KT3.js +187 -0
  8. package/dist/chunk-F7B64KT3.js.map +7 -0
  9. package/dist/chunk-FD37DFCC.js +77 -0
  10. package/dist/chunk-FD37DFCC.js.map +7 -0
  11. package/dist/chunk-H54FLNAF.js +132 -0
  12. package/dist/chunk-H54FLNAF.js.map +7 -0
  13. package/dist/chunk-INP46354.js +664 -0
  14. package/dist/chunk-INP46354.js.map +7 -0
  15. package/dist/chunk-ONACRMG4.js +116 -0
  16. package/dist/chunk-ONACRMG4.js.map +7 -0
  17. package/dist/chunk-SDZ3LROZ.js +7 -0
  18. package/dist/chunk-SDZ3LROZ.js.map +7 -0
  19. package/dist/chunk-TOZBR4GL.js +154 -0
  20. package/dist/chunk-TOZBR4GL.js.map +7 -0
  21. package/dist/chunk-UNEM2TRI.js +225 -0
  22. package/dist/chunk-UNEM2TRI.js.map +7 -0
  23. package/dist/chunk-VK3EQ34F.js +92 -0
  24. package/dist/chunk-VK3EQ34F.js.map +7 -0
  25. package/dist/chunk-WK2IIUFO.js +316 -0
  26. package/dist/chunk-WK2IIUFO.js.map +7 -0
  27. package/dist/chunk-WSPJTQAV.js +59 -0
  28. package/dist/chunk-WSPJTQAV.js.map +7 -0
  29. package/dist/chunk-XWP763SH.js +3 -2
  30. package/dist/chunk-XWP763SH.js.map +7 -1
  31. package/dist/chunk-Y2FNNAIL.js +80 -0
  32. package/dist/chunk-Y2FNNAIL.js.map +1 -0
  33. package/dist/{chunk-4A4BW3GR.js → chunk-ZF3OHCGV.js} +28 -5
  34. package/dist/chunk-ZF3OHCGV.js.map +7 -0
  35. package/dist/form.cjs +5 -11
  36. package/dist/form.cjs.map +1 -1
  37. package/dist/form.js +6 -12
  38. package/dist/form.js.map +1 -1
  39. package/dist/index.cjs +2879 -33936
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts +1 -0
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.js +126 -28780
  44. package/dist/internal/react-app-shell/index.d.cts +2 -22
  45. package/dist/internal/react-app-shell/index.d.ts +2 -22
  46. package/dist/internal/react-badge/index.d.cts +5 -0
  47. package/dist/internal/react-badge/index.d.ts +5 -0
  48. package/dist/internal/react-callout/index.d.cts +4 -0
  49. package/dist/internal/react-callout/index.d.ts +4 -0
  50. package/dist/internal/react-card/index.d.cts +8 -1
  51. package/dist/internal/react-card/index.d.ts +8 -1
  52. package/dist/internal/react-collapsible/index.d.cts +0 -3
  53. package/dist/internal/react-collapsible/index.d.ts +0 -3
  54. package/dist/internal/react-combobox/index.d.cts +0 -3
  55. package/dist/internal/react-combobox/index.d.ts +0 -3
  56. package/dist/internal/react-command/index.d.cts +0 -3
  57. package/dist/internal/react-command/index.d.ts +0 -3
  58. package/dist/internal/react-data-table/index.d.cts +0 -3
  59. package/dist/internal/react-data-table/index.d.ts +0 -3
  60. package/dist/internal/react-dialog/index.d.cts +0 -3
  61. package/dist/internal/react-dialog/index.d.ts +0 -3
  62. package/dist/internal/react-dropdown-menu/index.d.cts +0 -3
  63. package/dist/internal/react-dropdown-menu/index.d.ts +0 -3
  64. package/dist/internal/react-feedback-dialog/index.d.cts +0 -3
  65. package/dist/internal/react-feedback-dialog/index.d.ts +0 -3
  66. package/dist/internal/react-form/index.d.cts +2 -21
  67. package/dist/internal/react-form/index.d.ts +2 -21
  68. package/dist/internal/react-keyboard-shortcut/index.d.cts +0 -6
  69. package/dist/internal/react-keyboard-shortcut/index.d.ts +0 -6
  70. package/dist/internal/react-link-card/index.d.cts +8 -2
  71. package/dist/internal/react-link-card/index.d.ts +8 -2
  72. package/dist/internal/react-popover/index.d.cts +0 -3
  73. package/dist/internal/react-popover/index.d.ts +0 -3
  74. package/dist/internal/react-sheet/index.d.cts +0 -3
  75. package/dist/internal/react-sheet/index.d.ts +0 -3
  76. package/dist/internal/react-slot/index.d.cts +23 -0
  77. package/dist/internal/react-slot/index.d.ts +23 -0
  78. package/dist/internal/react-toast/index.d.cts +0 -3
  79. package/dist/internal/react-toast/index.d.ts +0 -3
  80. package/dist/internal/react-tooltip/index.d.cts +0 -3
  81. package/dist/internal/react-tooltip/index.d.ts +0 -3
  82. package/dist/react-accordion.js +125 -0
  83. package/dist/react-accordion.js.map +7 -0
  84. package/dist/react-ai.js +257 -0
  85. package/dist/react-ai.js.map +7 -0
  86. package/dist/react-analytics.js +1698 -0
  87. package/dist/react-analytics.js.map +7 -0
  88. package/dist/react-animated-text.js +164 -0
  89. package/dist/react-animated-text.js.map +7 -0
  90. package/dist/react-app-shell.js +631 -0
  91. package/dist/react-app-shell.js.map +7 -0
  92. package/dist/react-audience-feature-card.js +53 -0
  93. package/dist/react-audience-feature-card.js.map +7 -0
  94. package/dist/react-audio-room.js +166 -0
  95. package/dist/react-audio-room.js.map +7 -0
  96. package/dist/react-auth.js +211 -0
  97. package/dist/react-auth.js.map +7 -0
  98. package/dist/react-avatar-group.js +154 -0
  99. package/dist/react-avatar-group.js.map +7 -0
  100. package/dist/react-avatar.js +168 -0
  101. package/dist/react-avatar.js.map +7 -0
  102. package/dist/react-badge.js +86 -0
  103. package/dist/react-badge.js.map +7 -0
  104. package/dist/react-bottom-nav.js +67 -0
  105. package/dist/react-bottom-nav.js.map +7 -0
  106. package/dist/react-brand-network-cell.js +92 -0
  107. package/dist/react-brand-network-cell.js.map +7 -0
  108. package/dist/react-breadcrumbs.js +104 -0
  109. package/dist/react-breadcrumbs.js.map +7 -0
  110. package/dist/react-browser-chrome-mock.js +89 -0
  111. package/dist/react-browser-chrome-mock.js.map +7 -0
  112. package/dist/react-button.js +13 -0
  113. package/dist/react-button.js.map +7 -0
  114. package/dist/react-calendar.js +301 -0
  115. package/dist/react-calendar.js.map +7 -0
  116. package/dist/react-call-controls.js +113 -0
  117. package/dist/react-call-controls.js.map +7 -0
  118. package/dist/react-callout.js +152 -0
  119. package/dist/react-callout.js.map +7 -0
  120. package/dist/react-card-grid.js +34 -0
  121. package/dist/react-card-grid.js.map +7 -0
  122. package/dist/react-card.js +200 -0
  123. package/dist/react-card.js.map +7 -0
  124. package/dist/react-carousel.js +132 -0
  125. package/dist/react-carousel.js.map +7 -0
  126. package/dist/react-charts.js +509 -0
  127. package/dist/react-charts.js.map +7 -0
  128. package/dist/react-checkbox.js +156 -0
  129. package/dist/react-checkbox.js.map +7 -0
  130. package/dist/react-checklist.js +168 -0
  131. package/dist/react-checklist.js.map +7 -0
  132. package/dist/react-code-block.js +78 -0
  133. package/dist/react-code-block.js.map +7 -0
  134. package/dist/react-code-editor.js +184 -0
  135. package/dist/react-code-editor.js.map +7 -0
  136. package/dist/react-collapsible.js +192 -0
  137. package/dist/react-collapsible.js.map +7 -0
  138. package/dist/react-combobox.js +609 -0
  139. package/dist/react-combobox.js.map +7 -0
  140. package/dist/react-command-input.js +202 -0
  141. package/dist/react-command-input.js.map +7 -0
  142. package/dist/react-command.js +364 -0
  143. package/dist/react-command.js.map +7 -0
  144. package/dist/react-composer.js +2036 -0
  145. package/dist/react-composer.js.map +7 -0
  146. package/dist/react-content-protection.js +133 -0
  147. package/dist/react-content-protection.js.map +7 -0
  148. package/dist/react-conversation.js +1226 -0
  149. package/dist/react-conversation.js.map +7 -0
  150. package/dist/react-cookie-consent.js +291 -0
  151. package/dist/react-cookie-consent.js.map +7 -0
  152. package/dist/react-data-table.js +310 -0
  153. package/dist/react-data-table.js.map +7 -0
  154. package/dist/react-date-picker.js +95 -0
  155. package/dist/react-date-picker.js.map +7 -0
  156. package/dist/react-device-frame.js +137 -0
  157. package/dist/react-device-frame.js.map +7 -0
  158. package/dist/react-dialog.js +218 -0
  159. package/dist/react-dialog.js.map +7 -0
  160. package/dist/react-diff-viewer.js +460 -0
  161. package/dist/react-diff-viewer.js.map +7 -0
  162. package/dist/react-dropdown-menu.js +292 -0
  163. package/dist/react-dropdown-menu.js.map +7 -0
  164. package/dist/react-editor-status-bar.js +148 -0
  165. package/dist/react-editor-status-bar.js.map +7 -0
  166. package/dist/react-editor-tabs.js +159 -0
  167. package/dist/react-editor-tabs.js.map +7 -0
  168. package/dist/react-emoji-picker.js +238 -0
  169. package/dist/react-emoji-picker.js.map +7 -0
  170. package/dist/react-empty-state.js +90 -0
  171. package/dist/react-empty-state.js.map +7 -0
  172. package/dist/react-feedback-dialog.js +275 -0
  173. package/dist/react-feedback-dialog.js.map +7 -0
  174. package/dist/react-file-tree.js +376 -0
  175. package/dist/react-file-tree.js.map +7 -0
  176. package/dist/react-file-upload.js +360 -0
  177. package/dist/react-file-upload.js.map +7 -0
  178. package/dist/react-floating-reactions.js +124 -0
  179. package/dist/react-floating-reactions.js.map +7 -0
  180. package/dist/react-flow-editor.js +198 -0
  181. package/dist/react-flow-editor.js.map +7 -0
  182. package/dist/react-footer.js +67 -0
  183. package/dist/react-footer.js.map +7 -0
  184. package/dist/react-graph-view.js +197 -0
  185. package/dist/react-graph-view.js.map +7 -0
  186. package/dist/react-icon-system.js +9 -0
  187. package/dist/react-icon-system.js.map +7 -0
  188. package/dist/react-infinite-canvas.js +8 -0
  189. package/dist/react-infinite-canvas.js.map +7 -0
  190. package/dist/react-inline-editor.js +216 -0
  191. package/dist/react-inline-editor.js.map +7 -0
  192. package/dist/react-input-group.js +150 -0
  193. package/dist/react-input-group.js.map +7 -0
  194. package/dist/react-input.js +10 -0
  195. package/dist/react-input.js.map +7 -0
  196. package/dist/react-install-prompt.js +132 -0
  197. package/dist/react-install-prompt.js.map +7 -0
  198. package/dist/react-kanban-board.js +198 -0
  199. package/dist/react-kanban-board.js.map +7 -0
  200. package/dist/react-keyboard-shortcut.js +36 -0
  201. package/dist/react-keyboard-shortcut.js.map +7 -0
  202. package/dist/react-language-selector.js +311 -0
  203. package/dist/react-language-selector.js.map +7 -0
  204. package/dist/react-link-card.js +48 -0
  205. package/dist/react-link-card.js.map +7 -0
  206. package/dist/react-live-captions.js +92 -0
  207. package/dist/react-live-captions.js.map +7 -0
  208. package/dist/react-live-cursors.js +145 -0
  209. package/dist/react-live-cursors.js.map +7 -0
  210. package/dist/react-live-transcript.js +117 -0
  211. package/dist/react-live-transcript.js.map +7 -0
  212. package/dist/react-location-selector.js +252 -0
  213. package/dist/react-location-selector.js.map +7 -0
  214. package/dist/react-logger.js +415 -0
  215. package/dist/react-logger.js.map +7 -0
  216. package/dist/react-markdown-renderer.js +12 -0
  217. package/dist/react-markdown-renderer.js.map +7 -0
  218. package/dist/react-marquee-strip.js +62 -0
  219. package/dist/react-marquee-strip.js.map +7 -0
  220. package/dist/react-mascot.js +367 -0
  221. package/dist/react-mascot.js.map +7 -0
  222. package/dist/react-mastery-bar.js +97 -0
  223. package/dist/react-mastery-bar.js.map +7 -0
  224. package/dist/react-mini-map.js +207 -0
  225. package/dist/react-mini-map.js.map +7 -0
  226. package/dist/react-mobile-nav.js +216 -0
  227. package/dist/react-mobile-nav.js.map +7 -0
  228. package/dist/react-navbar.js +96 -0
  229. package/dist/react-navbar.js.map +7 -0
  230. package/dist/react-numbered-steps.js +67 -0
  231. package/dist/react-numbered-steps.js.map +7 -0
  232. package/dist/react-otp-input.js +318 -0
  233. package/dist/react-otp-input.js.map +7 -0
  234. package/dist/react-pagination.js +199 -0
  235. package/dist/react-pagination.js.map +7 -0
  236. package/dist/react-password-input.js +104 -0
  237. package/dist/react-password-input.js.map +7 -0
  238. package/dist/react-payment.js +81 -0
  239. package/dist/react-payment.js.map +7 -0
  240. package/dist/react-popover.js +176 -0
  241. package/dist/react-popover.js.map +7 -0
  242. package/dist/react-pre-call-lobby.js +309 -0
  243. package/dist/react-pre-call-lobby.js.map +7 -0
  244. package/dist/react-presence-indicator.js +86 -0
  245. package/dist/react-presence-indicator.js.map +7 -0
  246. package/dist/react-pricing-card.js +142 -0
  247. package/dist/react-pricing-card.js.map +7 -0
  248. package/dist/react-progress-display.js +188 -0
  249. package/dist/react-progress-display.js.map +7 -0
  250. package/dist/react-radial-gauge.js +193 -0
  251. package/dist/react-radial-gauge.js.map +7 -0
  252. package/dist/react-radio.js +169 -0
  253. package/dist/react-radio.js.map +7 -0
  254. package/dist/react-rating-scale.js +171 -0
  255. package/dist/react-rating-scale.js.map +7 -0
  256. package/dist/react-reaction-bar.js +111 -0
  257. package/dist/react-reaction-bar.js.map +7 -0
  258. package/dist/react-resizable-layout.js +298 -0
  259. package/dist/react-resizable-layout.js.map +7 -0
  260. package/dist/react-rich-editor.js +1 -0
  261. package/dist/react-rich-editor.js.map +7 -0
  262. package/dist/react-search-bar.js +285 -0
  263. package/dist/react-search-bar.js.map +7 -0
  264. package/dist/react-section-head.js +65 -0
  265. package/dist/react-section-head.js.map +7 -0
  266. package/dist/react-segmented-control.js +215 -0
  267. package/dist/react-segmented-control.js.map +7 -0
  268. package/dist/react-select.js +389 -0
  269. package/dist/react-select.js.map +7 -0
  270. package/dist/react-separator.js +86 -0
  271. package/dist/react-separator.js.map +7 -0
  272. package/dist/react-sheet.js +310 -0
  273. package/dist/react-sheet.js.map +7 -0
  274. package/dist/react-sidebar.js +100 -0
  275. package/dist/react-sidebar.js.map +7 -0
  276. package/dist/react-skeleton.js +91 -0
  277. package/dist/react-skeleton.js.map +7 -0
  278. package/dist/react-skip-to-content.js +38 -0
  279. package/dist/react-skip-to-content.js.map +7 -0
  280. package/dist/react-slide-viewer.js +264 -0
  281. package/dist/react-slide-viewer.js.map +7 -0
  282. package/dist/react-slider.js +105 -0
  283. package/dist/react-slider.js.map +7 -0
  284. package/dist/react-slot-picker.js +184 -0
  285. package/dist/react-slot-picker.js.map +7 -0
  286. package/dist/react-slot.js +7 -0
  287. package/dist/react-slot.js.map +7 -0
  288. package/dist/react-social-auth-button.js +169 -0
  289. package/dist/react-social-auth-button.js.map +7 -0
  290. package/dist/react-sortable-list.js +204 -0
  291. package/dist/react-sortable-list.js.map +7 -0
  292. package/dist/react-stat-grid.js +69 -0
  293. package/dist/react-stat-grid.js.map +7 -0
  294. package/dist/react-status-indicator.js +117 -0
  295. package/dist/react-status-indicator.js.map +7 -0
  296. package/dist/react-steps.js +167 -0
  297. package/dist/react-steps.js.map +7 -0
  298. package/dist/react-sticky-note.js +131 -0
  299. package/dist/react-sticky-note.js.map +7 -0
  300. package/dist/react-switch.js +139 -0
  301. package/dist/react-switch.js.map +7 -0
  302. package/dist/react-table-of-contents.js +80 -0
  303. package/dist/react-table-of-contents.js.map +7 -0
  304. package/dist/react-tabs.js +230 -0
  305. package/dist/react-tabs.js.map +7 -0
  306. package/dist/react-terminal.js +101 -0
  307. package/dist/react-terminal.js.map +7 -0
  308. package/dist/react-test-results.js +158 -0
  309. package/dist/react-test-results.js.map +7 -0
  310. package/dist/react-textarea.js +89 -0
  311. package/dist/react-textarea.js.map +7 -0
  312. package/dist/react-thread-view.js +139 -0
  313. package/dist/react-thread-view.js.map +7 -0
  314. package/dist/react-timeline.js +153 -0
  315. package/dist/react-timeline.js.map +7 -0
  316. package/dist/react-toast.js +253 -0
  317. package/dist/react-toast.js.map +7 -0
  318. package/dist/react-tooltip.js +221 -0
  319. package/dist/react-tooltip.js.map +7 -0
  320. package/dist/react-version-selector.js +270 -0
  321. package/dist/react-version-selector.js.map +7 -0
  322. package/dist/react-video-grid.js +129 -0
  323. package/dist/react-video-grid.js.map +7 -0
  324. package/dist/react-video-player.js +206 -0
  325. package/dist/react-video-player.js.map +7 -0
  326. package/dist/react-video-tile.js +8 -0
  327. package/dist/react-video-tile.js.map +7 -0
  328. package/dist/react-voice-pill.js +314 -0
  329. package/dist/react-voice-pill.js.map +7 -0
  330. package/dist/react-waveform.js +558 -0
  331. package/dist/react-waveform.js.map +7 -0
  332. package/dist/react-wizard.js +337 -0
  333. package/dist/react-wizard.js.map +7 -0
  334. package/dist/styles.css +7 -0
  335. package/dist/theme.js +1 -1
  336. package/package.json +3 -2
  337. package/dist/applicationinsights-web-H7OBLIVJ.js +0 -23393
  338. package/dist/applicationinsights-web-H7OBLIVJ.js.map +0 -1
  339. package/dist/chunk-4A4BW3GR.js.map +0 -1
  340. package/dist/index.js.map +0 -1
  341. package/dist/module-X3HTTRQK.js +0 -6438
  342. package/dist/module-X3HTTRQK.js.map +0 -1
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../shared/src/aria.ts", "../../shared/src/keyboard.ts", "../../shared/src/state-machine.ts", "../../shared/src/cn.ts", "../../shared/src/cva.ts", "../../shared/src/focus-trap.ts", "../../shared/src/live-region.ts", "../../shared/src/motion.ts", "../../shared/src/skip-link.ts", "../../shared/src/dev-feedback.ts", "../../shared/src/library-origin-error.ts"],
4
+ "sourcesContent": ["/** Merge multiple ARIA prop objects, later values override earlier ones */\nexport function mergeAriaProps(\n ...propSets: Array<Record<string, unknown>>\n): Record<string, unknown> {\n const result: Record<string, unknown> = {}\n for (const props of propSets) {\n for (const [key, value] of Object.entries(props)) {\n if (value !== undefined) {\n result[key] = value\n }\n }\n }\n return result\n}\n\nlet idCounter = 0\n\n/**\n * Generate a unique ID, safe for SSR (deterministic within a render pass).\n * In browsers, uses crypto.randomUUID when available.\n */\nexport function generateId(prefix = 'rfr'): string {\n idCounter++\n return `${prefix}-${idCounter}`\n}\n\n/** Reset the ID counter (useful for tests) */\nexport function resetIdCounter(): void {\n idCounter = 0\n}\n", "/** Standard keyboard key constants */\nexport const Keys = {\n Enter: 'Enter',\n Space: ' ',\n Escape: 'Escape',\n Tab: 'Tab',\n ArrowUp: 'ArrowUp',\n ArrowDown: 'ArrowDown',\n ArrowLeft: 'ArrowLeft',\n ArrowRight: 'ArrowRight',\n Home: 'Home',\n End: 'End',\n PageUp: 'PageUp',\n PageDown: 'PageDown',\n Backspace: 'Backspace',\n Delete: 'Delete',\n} as const\n\nexport type KeyboardKey = (typeof Keys)[keyof typeof Keys]\n\n/** Map of key → handler function */\nexport type KeyboardHandlerMap = Partial<\n Record<string, (event: KeyboardEvent) => void>\n>\n\n/** Create a keyboard event handler from a handler map */\nexport function createKeyboardHandler(\n handlers: KeyboardHandlerMap,\n): (event: KeyboardEvent) => void {\n return (event: KeyboardEvent) => {\n const handler = handlers[event.key]\n if (handler) {\n handler(event)\n }\n }\n}\n", "/**\n * Minimal state machine — zero dependencies, < 1KB.\n * Inspired by XState concepts but dramatically simpler.\n */\n\nexport interface MachineConfig<TState extends string, TEvent extends string> {\n initial: TState\n states: Record<TState, {\n on?: Partial<Record<TEvent, TState>>\n }>\n}\n\nexport interface Machine<TState extends string, TEvent extends string> {\n /** Current state */\n state: TState\n /** Send an event to transition */\n send(event: TEvent): void\n /** Subscribe to state changes. Returns unsubscribe function. */\n subscribe(fn: (state: TState) => void): () => void\n /** Check if machine is in a given state */\n matches(state: TState): boolean\n}\n\nexport function createMachine<TState extends string, TEvent extends string>(\n config: MachineConfig<TState, TEvent>,\n): Machine<TState, TEvent> {\n let current = config.initial\n const listeners = new Set<(state: TState) => void>()\n\n return {\n get state() {\n return current\n },\n\n send(event: TEvent) {\n const stateConfig = config.states[current]\n const next = stateConfig?.on?.[event]\n if (next && next !== current) {\n current = next\n for (const fn of listeners) {\n fn(current)\n }\n }\n },\n\n subscribe(fn: (state: TState) => void) {\n listeners.add(fn)\n return () => {\n listeners.delete(fn)\n }\n },\n\n matches(state: TState) {\n return current === state\n },\n }\n}\n", "/**\n * Lightweight class name utility — our own implementation.\n * Handles conditional classes, arrays, and falsy values.\n * No external dependencies (no clsx, no tailwind-merge).\n *\n * For Tailwind class conflict resolution (e.g., 'p-2 p-4' → 'p-4'),\n * consumers can use @refraction-ui/tailwind-config which provides\n * a tw-merge-aware variant of this function.\n */\n\ntype ClassValue = string | number | boolean | undefined | null | ClassValue[]\ntype ClassRecord = Record<string, boolean | undefined | null>\n\nexport function cn(...inputs: Array<ClassValue | ClassRecord>): string {\n const classes: string[] = []\n\n for (const input of inputs) {\n if (!input) continue\n\n if (typeof input === 'string') {\n classes.push(input)\n } else if (typeof input === 'number') {\n classes.push(String(input))\n } else if (Array.isArray(input)) {\n const nested = cn(...input)\n if (nested) classes.push(nested)\n } else if (typeof input === 'object') {\n for (const [key, value] of Object.entries(input)) {\n if (value) classes.push(key)\n }\n }\n }\n\n return classes.join(' ')\n}\n", "/**\n * Lightweight class-variance-authority alternative — zero dependencies.\n * Creates variant-driven class name functions for components.\n */\n\ninterface VariantConfig {\n [variant: string]: Record<string, string>\n}\n\ninterface CVAConfig<V extends VariantConfig> {\n base?: string\n variants?: V\n defaultVariants?: {\n [K in keyof V]?: keyof V[K]\n }\n compoundVariants?: Array<\n {\n [K in keyof V]?: keyof V[K]\n } & { class: string }\n >\n}\n\ntype VariantProps<V extends VariantConfig> = {\n [K in keyof V]?: keyof V[K]\n}\n\nexport function cva<V extends VariantConfig>(config: CVAConfig<V>) {\n return (props?: VariantProps<V> & { className?: string }): string => {\n const classes: string[] = []\n\n if (config.base) {\n classes.push(config.base)\n }\n\n if (config.variants) {\n for (const [variantKey, variantOptions] of Object.entries(config.variants)) {\n const selectedValue =\n (props as Record<string, unknown> | undefined)?.[variantKey] ??\n config.defaultVariants?.[variantKey]\n\n if (selectedValue != null) {\n const variantClass = (variantOptions as Record<string, string>)[\n selectedValue as string\n ]\n if (variantClass) {\n classes.push(variantClass)\n }\n }\n }\n }\n\n if (config.compoundVariants) {\n for (const compound of config.compoundVariants) {\n const { class: compoundClass, ...conditions } = compound\n let matches = true\n\n for (const [key, value] of Object.entries(conditions)) {\n const propValue =\n (props as Record<string, unknown>)?.[key] ??\n config.defaultVariants?.[key]\n if (propValue !== value) {\n matches = false\n break\n }\n }\n\n if (matches) {\n classes.push(compoundClass as string)\n }\n }\n }\n\n if (props?.className) {\n classes.push(props.className)\n }\n\n return classes.filter(Boolean).join(' ')\n }\n}\n", "/**\n * Focus trap utilities — keeps keyboard focus within a container.\n * Used by Dialog, DropdownMenu, and other overlay components.\n * Pure TypeScript, no DOM dependency (accepts element via parameter).\n */\n\n/** Selector for all natively focusable elements */\nexport const FOCUSABLE_SELECTOR =\n 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])'\n\n/** Get all focusable elements within a container */\nexport function getFocusableElements(container: Element): Element[] {\n return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR))\n}\n\n/** Configuration for creating a focus trap */\nexport interface FocusTrapConfig {\n /** The container element */\n container: Element\n /** Called to get the initial focus target */\n initialFocus?: () => Element | null\n /** Called when Escape is pressed */\n onEscape?: () => void\n /** Whether to return focus to trigger on deactivate */\n returnFocusOnDeactivate?: boolean\n}\n\n/** A focus trap instance */\nexport interface FocusTrap {\n activate(): void\n deactivate(): void\n isActive(): boolean\n}\n\n/** Create a focus trap that keeps Tab/Shift+Tab within a container */\nexport function createFocusTrap(config: FocusTrapConfig): FocusTrap {\n let active = false\n let previouslyFocused: Element | null = null\n\n function handleKeyDown(event: KeyboardEvent): void {\n if (event.key === 'Escape' && config.onEscape) {\n event.preventDefault()\n config.onEscape()\n return\n }\n\n if (event.key !== 'Tab') return\n\n const focusable = getFocusableElements(config.container)\n if (focusable.length === 0) return\n\n const first = focusable[0] as HTMLElement\n const last = focusable[focusable.length - 1] as HTMLElement\n\n if (event.shiftKey) {\n // Shift+Tab: if on first element, wrap to last\n if (document.activeElement === first) {\n event.preventDefault()\n last.focus()\n }\n } else {\n // Tab: if on last element, wrap to first\n if (document.activeElement === last) {\n event.preventDefault()\n first.focus()\n }\n }\n }\n\n return {\n activate() {\n if (active) return\n active = true\n\n // Remember the currently focused element so we can restore it later\n if (typeof document !== 'undefined') {\n previouslyFocused = document.activeElement\n }\n\n // Set initial focus\n if (config.initialFocus) {\n const target = config.initialFocus()\n if (target && 'focus' in target) {\n (target as HTMLElement).focus()\n }\n } else {\n const focusable = getFocusableElements(config.container)\n if (focusable.length > 0) {\n (focusable[0] as HTMLElement).focus()\n }\n }\n\n // Attach keydown listener to the container\n config.container.addEventListener(\n 'keydown',\n handleKeyDown as EventListener,\n )\n },\n\n deactivate() {\n if (!active) return\n active = false\n\n config.container.removeEventListener(\n 'keydown',\n handleKeyDown as EventListener,\n )\n\n // Restore focus to the previously focused element\n if (\n config.returnFocusOnDeactivate !== false &&\n previouslyFocused &&\n 'focus' in previouslyFocused\n ) {\n (previouslyFocused as HTMLElement).focus()\n }\n },\n\n isActive() {\n return active\n },\n }\n}\n", "/**\n * Screen reader announcement utility.\n * Creates and manages an aria-live region for dynamic content updates.\n */\n\nexport interface LiveRegionConfig {\n /** 'polite' (default) or 'assertive' */\n politeness?: 'polite' | 'assertive'\n /** Clear the announcement after this many ms. Default: 5000 */\n clearAfterMs?: number\n}\n\nexport interface LiveRegion {\n announce(message: string): void\n clear(): void\n destroy(): void\n}\n\n/** Create a live region that announces messages to screen readers */\nexport function createLiveRegion(config: LiveRegionConfig = {}): LiveRegion {\n const { politeness = 'polite', clearAfterMs = 5000 } = config\n let element: HTMLElement | null = null\n let clearTimeout: ReturnType<typeof setTimeout> | null = null\n\n function getElement(): HTMLElement {\n if (!element && typeof document !== 'undefined') {\n element = document.createElement('div')\n element.setAttribute('role', 'status')\n element.setAttribute('aria-live', politeness)\n element.setAttribute('aria-atomic', 'true')\n // Visually hidden but accessible to screen readers\n Object.assign(element.style, {\n position: 'absolute',\n width: '1px',\n height: '1px',\n padding: '0',\n margin: '-1px',\n overflow: 'hidden',\n clip: 'rect(0, 0, 0, 0)',\n whiteSpace: 'nowrap',\n border: '0',\n })\n document.body.appendChild(element)\n }\n return element!\n }\n\n return {\n announce(message: string): void {\n const el = getElement()\n if (!el) return\n\n // Clear any pending timeout\n if (clearTimeout !== null) {\n globalThis.clearTimeout(clearTimeout)\n }\n\n // Set text content — screen readers will detect the change via aria-live\n el.textContent = message\n\n if (clearAfterMs > 0) {\n clearTimeout = globalThis.setTimeout(() => {\n el.textContent = ''\n clearTimeout = null\n }, clearAfterMs)\n }\n },\n\n clear(): void {\n if (clearTimeout !== null) {\n globalThis.clearTimeout(clearTimeout)\n clearTimeout = null\n }\n if (element) {\n element.textContent = ''\n }\n },\n\n destroy(): void {\n if (clearTimeout !== null) {\n globalThis.clearTimeout(clearTimeout)\n clearTimeout = null\n }\n if (element && element.parentNode) {\n element.parentNode.removeChild(element)\n element = null\n }\n },\n }\n}\n", "/**\n * Reduced motion utilities.\n * Respects user preferences for reduced motion.\n */\n\n/** Check if user prefers reduced motion */\nexport function prefersReducedMotion(): boolean {\n if (typeof window === 'undefined') return false\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches\n}\n\n/** Get animation duration — returns '0ms' if reduced motion preferred */\nexport function getAnimationDuration(normalDuration: string): string {\n return prefersReducedMotion() ? '0ms' : normalDuration\n}\n", "/**\n * Skip-to-content link utility.\n * Provides a keyboard-accessible link that is visually hidden until focused.\n */\n\n/** Props for a skip-to-content link */\nexport interface SkipLinkProps {\n /** ID of the target element. Default: 'main-content' */\n targetId?: string\n /** Label text for the link. Default: 'Skip to main content' */\n label?: string\n}\n\n/** Create props for a skip-to-content link */\nexport function createSkipLink(props: SkipLinkProps = {}): {\n ariaProps: Record<string, string>\n href: string\n label: string\n /** CSS classes — visually hidden until focused */\n className: string\n} {\n const targetId = props.targetId ?? 'main-content'\n const label = props.label ?? 'Skip to main content'\n\n return {\n ariaProps: {\n role: 'link',\n 'aria-label': label,\n },\n href: `#${targetId}`,\n label,\n className:\n 'sr-only focus:not-sr-only focus:absolute focus:z-50 focus:p-4 focus:bg-white focus:text-black focus:underline',\n }\n}\n", "/**\n * dev-feedback — zero-dependency `devWarn` / `devError` primitives.\n *\n * Design constraints (epic #247, issue #248):\n * - Guarded by `process.env.NODE_ENV !== 'production'` so production bundlers\n * dead-code-strip every call (the guard is a static string compare that\n * minifiers fold to `false` in prod builds).\n * - Warn-once dedupe per `code` — a footgun is reported once, not on every\n * render.\n * - NO import of `@refraction-ui/logger` (no hard dependency on the telemetry\n * lib). Forwarding to a telemetry sink happens ONLY if the consumer\n * explicitly injects one (dependency inversion, never an import).\n */\n\n/**\n * Minimal structural shape of the record a telemetry sink consumes. This is a\n * deliberate structural mirror of `@refraction-ui/logger`'s `LogRecord` — it is\n * NOT imported, so `@refraction-ui/shared` keeps zero dependency on the\n * telemetry lib. A consumer that wires the real logger sink satisfies this\n * shape structurally.\n */\nexport interface DevFeedbackRecord {\n level: 'warn' | 'error'\n message: string\n timestamp: number\n /** Structured detail — the library-origin envelope lives here. */\n context: Record<string, unknown>\n}\n\n/**\n * The narrow contract a consumer-injected telemetry sink must satisfy. Kept\n * intentionally minimal and structural so the real `TelemetrySink` from\n * `@refraction-ui/logger` is assignable WITHOUT shared importing the logger.\n */\nexport interface DevFeedbackSink {\n /** Receive a single dev-feedback record. Must never throw to the caller. */\n log(record: DevFeedbackRecord): void\n}\n\n/**\n * Minimal ambient view of `process.env` so we can read `NODE_ENV` WITHOUT\n * pulling `@types/node` into this zero-dependency package. Accessed defensively\n * (the `typeof process === 'undefined'` guard) so this is safe in browsers too.\n */\ndeclare const process:\n | { env?: { NODE_ENV?: string } }\n | undefined\n\n/** Per-code dedupe set — module-scoped so it survives across calls. */\nconst seen = new Set<string>()\n\n/**\n * Optional, consumer-injected sink. `null` until a consumer explicitly wires\n * one via {@link setDevFeedbackSink}. Nothing phones home implicitly.\n */\nlet injectedSink: DevFeedbackSink | null = null\n\n/**\n * Wire an optional telemetry sink that {@link devWarn} / {@link devError}\n * forward to (in addition to the console). Inversion of control: the consumer\n * owns the sink; this package never imports it. Pass `null` to unwire.\n *\n * Forwarding still only happens in non-production (the calls themselves are\n * stripped in prod), and still respects warn-once dedupe.\n */\nexport function setDevFeedbackSink(sink: DevFeedbackSink | null): void {\n injectedSink = sink\n}\n\n/** Test-only / consumer-only escape hatch to reset warn-once dedupe state. */\nexport function resetDevFeedback(): void {\n seen.clear()\n}\n\nfunction isDev(): boolean {\n // String compare (not a negated truthiness) so bundlers can statically fold\n // `process.env.NODE_ENV` and strip the whole branch in production builds.\n return (\n typeof process === 'undefined' ||\n process.env?.NODE_ENV !== 'production'\n )\n}\n\nfunction emit(\n level: 'warn' | 'error',\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n if (!isDev()) return\n\n // Warn-once dedupe, keyed by (level, code) so an error and a warning sharing\n // a code are not collapsed into one.\n const key = `${level}:${code}`\n if (seen.has(key)) return\n seen.add(key)\n\n const text = `[refraction-ui] ${code}: ${message}`\n\n if (level === 'error') {\n console.error(text, detail ?? '')\n } else {\n console.warn(text, detail ?? '')\n }\n\n // Forward to the consumer-injected sink ONLY if one was explicitly wired.\n if (injectedSink) {\n const record: DevFeedbackRecord = {\n level,\n message: `${code}: ${message}`,\n timestamp: Date.now(),\n context: { code, ...(detail ?? {}) },\n }\n try {\n injectedSink.log(record)\n } catch {\n // A broken sink must never break the consumer app.\n }\n }\n}\n\n/**\n * Emit a development-only warning for a refraction-ui footgun.\n *\n * @param code Stable, greppable identifier (e.g. `'react/no-controlled-prop'`).\n * @param message Human-readable explanation.\n * @param detail Optional structured detail (forwarded to an injected sink).\n *\n * Stripped entirely in production. Warned at most once per `code`.\n */\nexport function devWarn(\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n emit('warn', code, message, detail)\n}\n\n/**\n * Emit a development-only error for a refraction-ui misuse / invariant break.\n *\n * @param code Stable, greppable identifier.\n * @param message Human-readable explanation.\n * @param detail Optional structured detail (forwarded to an injected sink).\n *\n * Stripped entirely in production. Reported at most once per `code`.\n */\nexport function devError(\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n emit('error', code, message, detail)\n}\n", "/**\n * library-origin-error — builds the **library-origin error envelope** for\n * errors that originate inside a `@refraction-ui/*` package.\n *\n * The envelope is expressed THROUGH the existing telemetry record contract\n * (`@refraction-ui/logger`'s `LogRecord`) — the contract is reused, NOT\n * redefined. To keep `@refraction-ui/shared` zero-dependency, the record is\n * mirrored structurally (see {@link DevFeedbackRecord}) rather than imported;\n * a consumer wiring the real logger sink satisfies it structurally.\n *\n * Aggressive redaction (epic #247 guardrails): the payload is package,\n * componentName, version, a normalized stack **fingerprint hash**, and\n * framework only. Never app state, props values, user data, PII, or full app\n * stack frames.\n */\n\nimport type { DevFeedbackRecord, DevFeedbackSink } from './dev-feedback.js'\n\n/** Matches any stack frame that references a `@refraction-ui/*` package. */\nconst REFRACTION_FRAME = /@refraction-ui\\//\n\n/** Frameworks a refraction-ui adapter can run under. */\nexport type LibraryFramework =\n | 'react'\n | 'astro'\n | 'vue'\n | 'svelte'\n | 'vanilla'\n | 'unknown'\n\n/** Inputs describing where a library-origin error came from. */\nexport interface LibraryOriginErrorInput {\n /** Originating package, e.g. `@refraction-ui/react`. */\n package: string\n /** refraction-ui component the error originated in, e.g. `Dialog`. */\n componentName: string\n /** Originating package version, e.g. `0.1.5`. */\n version: string\n /** Host framework the component was running under. */\n framework: LibraryFramework\n /** The thrown error (or its stack string). Used ONLY to derive a hash. */\n error?: unknown\n}\n\n/**\n * The redacted, library-origin payload carried in `LogRecord.context`. Contains\n * NO app data — only the five identifying fields plus a stack fingerprint hash.\n */\nexport interface LibraryOriginEnvelope {\n /** Marks this record as a library-origin error (for downstream routing). */\n origin: 'refraction-ui'\n package: string\n componentName: string\n version: string\n framework: LibraryFramework\n /** Stable, app-data-free hash of the normalized stack. */\n fingerprint: string\n}\n\n/**\n * Normalize a stack trace into a deterministic, app-data-free string before\n * hashing:\n * - keep only frames that reference a `@refraction-ui/*` package (drop the\n * app's own frames — library-origin only),\n * - strip absolute paths, line/column numbers, query strings, and hashes,\n * - sort-free (preserve call order) but whitespace-collapsed.\n *\n * If no refraction-ui frames are present the function returns an empty string,\n * which yields a stable \"no-frames\" fingerprint rather than leaking app frames.\n */\nfunction normalizeStack(stack: string): string {\n const frames = stack\n .split('\\n')\n .map((line) => line.trim())\n .filter((line) => line.startsWith('at ') || line.includes('@'))\n .filter((line) => REFRACTION_FRAME.test(line))\n .map((line) =>\n line\n // drop everything from the path/url onward, keep the symbol\n .replace(/\\((?:.*?)(@refraction-ui\\/[^):]+)[^)]*\\)/, '($1)')\n .replace(/(@refraction-ui\\/[^\\s:?#]+)[^\\s)]*/g, '$1')\n // strip :line:col\n .replace(/:\\d+:\\d+/g, '')\n // strip line:col without colon prefix\n .replace(/:\\d+\\b/g, '')\n // strip query/hash\n .replace(/[?#][^\\s)]*/g, '')\n .replace(/\\s+/g, ' ')\n .trim(),\n )\n\n return frames.join('\\n')\n}\n\n/**\n * Deterministic, dependency-free 53-bit string hash (cyrb53). Stable across\n * runs and processes for the same input — required so the intake can dedupe by\n * fingerprint. NOT cryptographic; it only needs to be collision-resistant\n * enough to group identical normalized stacks.\n */\nfunction cyrb53(str: string, seed = 0): string {\n let h1 = 0xdeadbeef ^ seed\n let h2 = 0x41c6ce57 ^ seed\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i)\n h1 = Math.imul(h1 ^ ch, 2654435761)\n h2 = Math.imul(h2 ^ ch, 1597334677)\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)\n const out = 4294967296 * (2097151 & h2) + (h1 >>> 0)\n return out.toString(16).padStart(14, '0')\n}\n\nfunction stackOf(error: unknown): string {\n if (typeof error === 'string') return error\n if (\n error &&\n typeof error === 'object' &&\n 'stack' in error &&\n typeof (error as { stack?: unknown }).stack === 'string'\n ) {\n return (error as { stack: string }).stack\n }\n return ''\n}\n\n/**\n * Compute the stable stack fingerprint for a library-origin error. Exposed\n * separately so capture seams / tests can assert fingerprint stability without\n * building the whole record.\n */\nexport function stackFingerprint(error: unknown): string {\n const normalized = normalizeStack(stackOf(error))\n return cyrb53(normalized)\n}\n\n/**\n * Build the redacted library-origin envelope for an error.\n */\nexport function libraryOriginEnvelope(\n input: LibraryOriginErrorInput,\n): LibraryOriginEnvelope {\n return {\n origin: 'refraction-ui',\n package: input.package,\n componentName: input.componentName,\n version: input.version,\n framework: input.framework,\n fingerprint: stackFingerprint(input.error),\n }\n}\n\n/**\n * Build the full library-origin error record, expressed THROUGH the existing\n * telemetry record contract (`LogRecord`, mirrored as {@link DevFeedbackRecord}\n * to avoid a hard logger dependency). The redacted envelope rides in\n * `context`; no app data, props, PII, or app stack frames are included.\n *\n * This record is exactly what a consumer-wired telemetry sink (or the\n * `devWarn`/`devError` injected sink) consumes.\n */\nexport function libraryOriginError(\n input: LibraryOriginErrorInput,\n): DevFeedbackRecord {\n const envelope = libraryOriginEnvelope(input)\n return {\n level: 'error',\n message: `${input.package}/${input.componentName}: library-origin error`,\n timestamp: Date.now(),\n context: { ...envelope },\n }\n}\n\n/**\n * Library-origin predicate — `true` iff the error's stack contains at least\n * one frame that references a `@refraction-ui/*` package. This is the gate\n * every per-framework capture seam uses: only library-origin errors are\n * eligible; the app's own errors return `false` and pass through untouched.\n *\n * Mirrors exactly the frame-detection rule {@link stackFingerprint} normalizes\n * by — no new contract, just the companion predicate the seams need. Never\n * throws for a missing/odd error (returns `false`).\n */\nexport function isLibraryOriginError(error: unknown): boolean {\n const stack = stackOf(error)\n if (!stack) return false\n return REFRACTION_FRAME.test(stack)\n}\n\n/**\n * The fixed identity of the refraction-ui package/component a seam tags an\n * error with. The seam supplies this; the stack itself supplies the\n * fingerprint. Never carries app data.\n */\nexport type LibraryOriginIdentity = Pick<\n LibraryOriginErrorInput,\n 'package' | 'componentName' | 'version' | 'framework'\n>\n\n/**\n * The single capture primitive shared by every per-framework seam (React error\n * boundary, Astro middleware). It performs the entire\n * guarded flow in one place so the seams stay thin and identical in behavior:\n *\n * 1. **Library-origin filter** — if the error's stack has no\n * `@refraction-ui/*` frame it is the app's own error: return `null` and do\n * NOT touch, capture, or forward it.\n * 2. **Tag** — build the redacted {@link libraryOriginError} record\n * (package/componentName/version/framework + app-data-free fingerprint).\n * 3. **Route to the optional sink** — forward the record to the\n * consumer-injected sink ONLY if one was wired; a broken sink can never\n * break the consumer app. With no sink this is a no-op beyond returning\n * the record (so a seam can still surface it locally).\n *\n * @returns the tagged record for a library-origin error, or `null` when the\n * error is app-origin (the \"pass through untouched\" signal).\n */\nexport function captureLibraryOriginError(\n error: unknown,\n identity: LibraryOriginIdentity,\n sink: DevFeedbackSink | null | undefined,\n): DevFeedbackRecord | null {\n if (!isLibraryOriginError(error)) return null\n\n const record = libraryOriginError({ ...identity, error })\n\n if (sink) {\n try {\n sink.log(record)\n } catch {\n // A broken sink must never break the consumer app.\n }\n }\n\n return record\n}\n"],
5
+ "mappings": ";AAeA,IAAI,YAAY;AAMT,SAAS,WAAW,SAAS,OAAe;AACjD;AACA,SAAO,GAAG,MAAM,IAAI,SAAS;AAC/B;ACvBO,IAAM,OAAO;EAClB,OAAO;EACP,OAAO;EACP,QAAQ;EACR,KAAK;EACL,SAAS;EACT,WAAW;EACX,WAAW;EACX,YAAY;EACZ,MAAM;EACN,KAAK;EACL,QAAQ;EACR,UAAU;EACV,WAAW;EACX,QAAQ;AACV;AAUO,SAAS,sBACd,UACgC;AAChC,SAAO,CAAC,UAAyB;AAC/B,UAAM,UAAU,SAAS,MAAM,GAAG;AAClC,QAAI,SAAS;AACX,cAAQ,KAAK;IACf;EACF;AACF;ACZO,SAAS,cACd,QACyB;AACzB,MAAI,UAAU,OAAO;AACrB,QAAM,YAAA,oBAAgB,IAAA;AAEtB,SAAO;IACL,IAAI,QAAQ;AACV,aAAO;IACT;IAEA,KAAK,OAAe;AAClB,YAAM,cAAc,OAAO,OAAO,OAAO;AACzC,YAAM,OAAO,aAAa,KAAK,KAAK;AACpC,UAAI,QAAQ,SAAS,SAAS;AAC5B,kBAAU;AACV,mBAAW,MAAM,WAAW;AAC1B,aAAG,OAAO;QACZ;MACF;IACF;IAEA,UAAU,IAA6B;AACrC,gBAAU,IAAI,EAAE;AAChB,aAAO,MAAM;A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gBAAM,YACH,QAAoC,GAAG,KACxC,OAAO,kBAAkB,GAAG;AAC9B,cAAI,cAAc,OAAO;AACvB,sBAAU;AACV;UACF;QACF;AAEA,YAAI,SAAS;AACX,kBAAQ,KAAK,aAAuB;QACtC;MACF;IACF;AAEA,QAAI,OAAO,WAAW;AACpB,cAAQ,KAAK,MAAM,SAAS;IAC9B;AAEA,WAAO,QAAQ,OAAO,OAAO,EAAE,KAAK,GAAG;EACzC;AACF;AGxEO,SAAS,uBAAgC;AAC9C,MAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,SAAO,OAAO,WAAW,kCAAkC,EAAE;AAC/D;AEwCA,IAAM,OAAA,oBAAW,IAAA;AAMjB,IAAI,eAAuC;AAmB3C,SAAS,QAAiB;AAGxB,SACE,OAAO,YAAY,eACnB;AAEJ;AAEA,SAAS,KACP,OACA,MACA,SACA,QACM;AACN,MAAI,CAAC,MAAA,EAAS;AAId,QAAM,MAAM,GAAG,KAAK,IAAI,IAAI;AAC5B,MAAI,KAAK,IAAI,GAAG,EAAG;AACnB,OAAK,IAAI,GAAG;AAEZ,QAAM,OAAO,mBAAmB,IAAI,KAAK,OAAO;AAEhD,MAAI,UAAU,SAAS;AACrB,YAAQ,MAAM,MAAM,UAAU,EAAE;EAClC,OAAO;AACL,YAAQ,KAAK,MAAM,UAAU,EAAE;EACjC;AAGA,MAAI,cAAc;AAChB,UAAM,SAA4B;MAChC;MACA,SAAS,GAAG,IAAI,KAAK,OAAO;MAC5B,WAAW,KAAK,IAAA;MAChB,SAAS,EAAE,MAAM,GAAI,UAAU,CAAA,EAAC;IAAG;AAErC,QAAI;AACF,mBAAa,IAAI,MAAM;IACzB,QAAQ;IAER;EACF;AACF;AAWO,SAAS,QACd,MACA,SACA,QACM;AACN,OAAK,QAAQ,MAAM,SAAS,MAAM;AACpC;",
6
+ "names": []
7
+ }
package/dist/form.cjs CHANGED
@@ -121,7 +121,6 @@ var Slot = React2__namespace.forwardRef(function Slot2(props, forwardedRef) {
121
121
  { ...mergedProps, ref: mergedRef }
122
122
  );
123
123
  });
124
- Slot.displayName = "Slot";
125
124
  function mergeProps(slotProps, childProps) {
126
125
  const merged = { ...slotProps };
127
126
  for (const key of Object.keys(childProps)) {
@@ -216,12 +215,11 @@ function getNestedError(errors, name) {
216
215
  }
217
216
  var formItemVariants = cva({ base: "space-y-2" });
218
217
  var FormItem = React2__namespace.forwardRef(
219
- ({ className, ...props }, ref) => {
218
+ function FormItem2({ className, ...props }, ref) {
220
219
  const id = React2__namespace.useId();
221
220
  return /* @__PURE__ */ jsxRuntime.jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn(formItemVariants(), className), ...props }) });
222
221
  }
223
222
  );
224
- FormItem.displayName = "FormItem";
225
223
  var formLabelVariants = cva({
226
224
  base: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
227
225
  variants: {
@@ -235,7 +233,7 @@ var formLabelVariants = cva({
235
233
  }
236
234
  });
237
235
  var FormLabel = React2__namespace.forwardRef(
238
- ({ className, ...props }, ref) => {
236
+ function FormLabel2({ className, ...props }, ref) {
239
237
  const { invalid, formItemId } = useFormField();
240
238
  return /* @__PURE__ */ jsxRuntime.jsx(
241
239
  "label",
@@ -249,9 +247,8 @@ var FormLabel = React2__namespace.forwardRef(
249
247
  );
250
248
  }
251
249
  );
252
- FormLabel.displayName = "FormLabel";
253
250
  var FormControl = React2__namespace.forwardRef(
254
- ({ ...props }, ref) => {
251
+ function FormControl2({ ...props }, ref) {
255
252
  const { invalid, formItemId, formDescriptionId, formMessageId } = useFormField();
256
253
  return /* @__PURE__ */ jsxRuntime.jsx(
257
254
  Slot,
@@ -265,8 +262,7 @@ var FormControl = React2__namespace.forwardRef(
265
262
  );
266
263
  }
267
264
  );
268
- FormControl.displayName = "FormControl";
269
- var FormDescription = React2__namespace.forwardRef(({ className, ...props }, ref) => {
265
+ var FormDescription = React2__namespace.forwardRef(function FormDescription2({ className, ...props }, ref) {
270
266
  const { formDescriptionId } = useFormField();
271
267
  return /* @__PURE__ */ jsxRuntime.jsx(
272
268
  "p",
@@ -278,9 +274,8 @@ var FormDescription = React2__namespace.forwardRef(({ className, ...props }, ref
278
274
  }
279
275
  );
280
276
  });
281
- FormDescription.displayName = "FormDescription";
282
277
  var FormMessage = React2__namespace.forwardRef(
283
- ({ className, children, ...props }, ref) => {
278
+ function FormMessage2({ className, children, ...props }, ref) {
284
279
  const { error, formMessageId } = useFormField();
285
280
  const body = error?.message ? String(error.message) : children;
286
281
  if (!body) return null;
@@ -296,7 +291,6 @@ var FormMessage = React2__namespace.forwardRef(
296
291
  );
297
292
  }
298
293
  );
299
- FormMessage.displayName = "FormMessage";
300
294
 
301
295
  Object.defineProperty(exports, "Controller", {
302
296
  enumerable: true,
package/dist/form.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../shared/src/cn.ts","../../shared/src/cva.ts","../../shared/src/dev-feedback.ts","../../react-form/src/slot.tsx","../../react-form/src/form.tsx"],"names":["React2","Slot","FormProvider","Controller","useFormContext","useFormState","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,MAAM,MAAA,EAAiD;AACrE,EAAA,MAAM,UAAoB,EAAA;AAE1B,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,MAAA,OAAA,CAAQ,KAAK,KAAK,CAAA;IACpB,CAAA,MAAA,IAAW,OAAO,UAAU,QAAA,EAAU;AACpC,MAAA,OAAA,CAAQ,IAAA,CAAK,MAAA,CAAO,KAAK,CAAC,CAAA;IAC5B,CAAA,MAAA,IAAW,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC/B,MAAA,MAAM,MAAA,GAAS,EAAA,CAAG,GAAG,KAAK,CAAA;AAC1B,MAAA,IAAI,MAAA,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AAA;AAC9B,EAAA,uBACEM,cAAA;AAAC,IAAA,GAAA;AAAA,IAAA;AACC,MAAA,GAAA;MACA,EAAA,EAAI,iBAAA;MACJ,SAAA,EAAW,EAAA,CAAG,iCAAiC,SAAS,CAAA;MACvD,GAAG;AAAA;AAAA,GAAA;AAGV,CAAC;AACD,eAAA,CAAgB,WAAA,GAAc,iBAAA;AAQ9B,IAAM,WAAA,GAAoBN,iBAAA,CAAA,UAAA;AACxB,EAAA,CAAC,EAAE,SAAA,EAAW,QAAA,EAAU,GAAG,KAAA,IAAS,GAAA,KAAQ;AAC1C,IAAA,MAAM,EAAE,KAAA,EAAO,aAAA,EAAA,GAAkB,YAAA,EAAA;AACjC,IAAA,MAAM,OAAO,KAAA,EAAO,OAAA,GAAU,MAAA,CAAO,KAAA,CAAM,OAAO,CAAA,GAAI,QAAA;AACtD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,IAAA,uBACEM,cAAA;AAAC,MAAA,GAAA;AAAA,MAAA;AACC,QAAA,GAAA;QACA,EAAA,EAAI,aAAA;QACJ,SAAA,EAAW,EAAA,CAAG,wCAAwC,SAAS,CAAA;QAC9D,GAAG,KAAA;QAEH,QAAA,EAAA;AAAA;AAAA,KAAA;AAGP,EAAA;AACF;AACA,WAAA,CAAY,WAAA,GAAc,aAAA","file":"form.cjs","sourcesContent":["/**\n * Lightweight class name utility — our own implementation.\n * Handles conditional classes, arrays, and falsy values.\n * No external dependencies (no clsx, no tailwind-merge).\n *\n * For Tailwind class conflict resolution (e.g., 'p-2 p-4' → 'p-4'),\n * consumers can use @refraction-ui/tailwind-config which provides\n * a tw-merge-aware variant of this function.\n */\n\ntype ClassValue = string | number | boolean | undefined | null | ClassValue[]\ntype ClassRecord = Record<string, boolean | undefined | null>\n\nexport function cn(...inputs: Array<ClassValue | ClassRecord>): string {\n const classes: string[] = []\n\n for (const input of inputs) {\n if (!input) continue\n\n if (typeof input === 'string') {\n classes.push(input)\n } else if (typeof input === 'number') {\n classes.push(String(input))\n } else if (Array.isArray(input)) {\n const nested = cn(...input)\n if (nested) classes.push(nested)\n } else if (typeof input === 'object') {\n for (const [key, value] of Object.entries(input)) {\n if (value) classes.push(key)\n }\n }\n }\n\n return classes.join(' ')\n}\n","/**\n * Lightweight class-variance-authority alternative — zero dependencies.\n * Creates variant-driven class name functions for components.\n */\n\ninterface VariantConfig {\n [variant: string]: Record<string, string>\n}\n\ninterface CVAConfig<V extends VariantConfig> {\n base?: string\n variants?: V\n defaultVariants?: {\n [K in keyof V]?: keyof V[K]\n }\n compoundVariants?: Array<\n {\n [K in keyof V]?: keyof V[K]\n } & { class: string }\n >\n}\n\ntype VariantProps<V extends VariantConfig> = {\n [K in keyof V]?: keyof V[K]\n}\n\nexport function cva<V extends VariantConfig>(config: CVAConfig<V>) {\n return (props?: VariantProps<V> & { className?: string }): string => {\n const classes: string[] = []\n\n if (config.base) {\n classes.push(config.base)\n }\n\n if (config.variants) {\n for (const [variantKey, variantOptions] of Object.entries(config.variants)) {\n const selectedValue =\n (props as Record<string, unknown> | undefined)?.[variantKey] ??\n config.defaultVariants?.[variantKey]\n\n if (selectedValue != null) {\n const variantClass = (variantOptions as Record<string, string>)[\n selectedValue as string\n ]\n if (variantClass) {\n classes.push(variantClass)\n }\n }\n }\n }\n\n if (config.compoundVariants) {\n for (const compound of config.compoundVariants) {\n const { class: compoundClass, ...conditions } = compound\n let matches = true\n\n for (const [key, value] of Object.entries(conditions)) {\n const propValue =\n (props as Record<string, unknown>)?.[key] ??\n config.defaultVariants?.[key]\n if (propValue !== value) {\n matches = false\n break\n }\n }\n\n if (matches) {\n classes.push(compoundClass as string)\n }\n }\n }\n\n if (props?.className) {\n classes.push(props.className)\n }\n\n return classes.filter(Boolean).join(' ')\n }\n}\n","/**\n * dev-feedback — zero-dependency `devWarn` / `devError` primitives.\n *\n * Design constraints (epic #247, issue #248):\n * - Guarded by `process.env.NODE_ENV !== 'production'` so production bundlers\n * dead-code-strip every call (the guard is a static string compare that\n * minifiers fold to `false` in prod builds).\n * - Warn-once dedupe per `code` — a footgun is reported once, not on every\n * render.\n * - NO import of `@refraction-ui/logger` (no hard dependency on the telemetry\n * lib). Forwarding to a telemetry sink happens ONLY if the consumer\n * explicitly injects one (dependency inversion, never an import).\n */\n\n/**\n * Minimal structural shape of the record a telemetry sink consumes. This is a\n * deliberate structural mirror of `@refraction-ui/logger`'s `LogRecord` — it is\n * NOT imported, so `@refraction-ui/shared` keeps zero dependency on the\n * telemetry lib. A consumer that wires the real logger sink satisfies this\n * shape structurally.\n */\nexport interface DevFeedbackRecord {\n level: 'warn' | 'error'\n message: string\n timestamp: number\n /** Structured detail — the library-origin envelope lives here. */\n context: Record<string, unknown>\n}\n\n/**\n * The narrow contract a consumer-injected telemetry sink must satisfy. Kept\n * intentionally minimal and structural so the real `TelemetrySink` from\n * `@refraction-ui/logger` is assignable WITHOUT shared importing the logger.\n */\nexport interface DevFeedbackSink {\n /** Receive a single dev-feedback record. Must never throw to the caller. */\n log(record: DevFeedbackRecord): void\n}\n\n/**\n * Minimal ambient view of `process.env` so we can read `NODE_ENV` WITHOUT\n * pulling `@types/node` into this zero-dependency package. Accessed defensively\n * (the `typeof process === 'undefined'` guard) so this is safe in browsers too.\n */\ndeclare const process:\n | { env?: { NODE_ENV?: string } }\n | undefined\n\n/** Per-code dedupe set — module-scoped so it survives across calls. */\nconst seen = new Set<string>()\n\n/**\n * Optional, consumer-injected sink. `null` until a consumer explicitly wires\n * one via {@link setDevFeedbackSink}. Nothing phones home implicitly.\n */\nlet injectedSink: DevFeedbackSink | null = null\n\n/**\n * Wire an optional telemetry sink that {@link devWarn} / {@link devError}\n * forward to (in addition to the console). Inversion of control: the consumer\n * owns the sink; this package never imports it. Pass `null` to unwire.\n *\n * Forwarding still only happens in non-production (the calls themselves are\n * stripped in prod), and still respects warn-once dedupe.\n */\nexport function setDevFeedbackSink(sink: DevFeedbackSink | null): void {\n injectedSink = sink\n}\n\n/** Test-only / consumer-only escape hatch to reset warn-once dedupe state. */\nexport function resetDevFeedback(): void {\n seen.clear()\n}\n\nfunction isDev(): boolean {\n // String compare (not a negated truthiness) so bundlers can statically fold\n // `process.env.NODE_ENV` and strip the whole branch in production builds.\n return (\n typeof process === 'undefined' ||\n process.env?.NODE_ENV !== 'production'\n )\n}\n\nfunction emit(\n level: 'warn' | 'error',\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n if (!isDev()) return\n\n // Warn-once dedupe, keyed by (level, code) so an error and a warning sharing\n // a code are not collapsed into one.\n const key = `${level}:${code}`\n if (seen.has(key)) return\n seen.add(key)\n\n const text = `[refraction-ui] ${code}: ${message}`\n\n if (level === 'error') {\n console.error(text, detail ?? '')\n } else {\n console.warn(text, detail ?? '')\n }\n\n // Forward to the consumer-injected sink ONLY if one was explicitly wired.\n if (injectedSink) {\n const record: DevFeedbackRecord = {\n level,\n message: `${code}: ${message}`,\n timestamp: Date.now(),\n context: { code, ...(detail ?? {}) },\n }\n try {\n injectedSink.log(record)\n } catch {\n // A broken sink must never break the consumer app.\n }\n }\n}\n\n/**\n * Emit a development-only warning for a refraction-ui footgun.\n *\n * @param code Stable, greppable identifier (e.g. `'react/no-controlled-prop'`).\n * @param message Human-readable explanation.\n * @param detail Optional structured detail (forwarded to an injected sink).\n *\n * Stripped entirely in production. Warned at most once per `code`.\n */\nexport function devWarn(\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n emit('warn', code, message, detail)\n}\n\n/**\n * Emit a development-only error for a refraction-ui misuse / invariant break.\n *\n * @param code Stable, greppable identifier.\n * @param message Human-readable explanation.\n * @param detail Optional structured detail (forwarded to an injected sink).\n *\n * Stripped entirely in production. Reported at most once per `code`.\n */\nexport function devError(\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n emit('error', code, message, detail)\n}\n","import * as React from 'react'\n\n/**\n * Minimal Slot implementation.\n *\n * Why not @radix-ui/react-slot? Per package policy, no external runtime deps\n * are allowed in @refraction-ui/* packages. This Slot does the small amount\n * of work we actually need:\n * - Forwards a single React child\n * - Merges incoming props onto that child (event handlers are chained,\n * className is concatenated, style is shallow-merged)\n * - Merges refs (callback refs and ref objects)\n *\n * It is intentionally simpler than Radix Slot — no <Slottable/>, no asChild\n * recursion. FormControl renders exactly one child input/textarea/etc., which\n * is all we need here.\n */\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>(function Slot(\n props,\n forwardedRef,\n) {\n const { children, ...slotProps } = props\n\n if (!React.isValidElement(children)) {\n return null\n }\n\n // The child element's existing props\n const childProps = (children.props ?? {}) as Record<string, unknown>\n\n const mergedProps = mergeProps(slotProps as Record<string, unknown>, childProps)\n\n // Forward + merge refs. In React 19 `ref` is a regular prop on `props`; in\n // React 18 it's hoisted onto the element. Prefer the prop and only fall back\n // to the element field if `props.ref` truly wasn't there — that fallback path\n // is React 18 only.\n let childRef: React.Ref<unknown> | undefined = childProps.ref as\n | React.Ref<unknown>\n | undefined\n if (childRef === undefined && !('ref' in (childProps as object))) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n childRef = (children as any).ref as React.Ref<unknown> | undefined\n }\n const mergedRef = composeRefs(forwardedRef as React.Ref<unknown>, childRef)\n\n return React.cloneElement(\n children as React.ReactElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { ...mergedProps, ref: mergedRef } as any,\n )\n})\n\nSlot.displayName = 'Slot'\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps }\n\n for (const key of Object.keys(childProps)) {\n const slotValue = slotProps[key]\n const childValue = childProps[key]\n\n // Chain event handlers: child's handler runs after slot's\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function' && typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n const child = childValue as (...a: unknown[]) => unknown\n const slot = slotValue as (...a: unknown[]) => unknown\n child(...args)\n slot(...args)\n }\n } else if (key === 'className') {\n merged[key] = [slotValue, childValue].filter(Boolean).join(' ')\n } else if (key === 'style') {\n merged[key] = { ...(slotValue as object), ...(childValue as object) }\n } else if (childValue !== undefined) {\n // Child wins for non-event, non-merged props\n merged[key] = childValue\n }\n }\n\n return merged\n}\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\nfunction composeRefs<T>(...refs: Array<PossibleRef<T>>): React.RefCallback<T> {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref != null) {\n const objectRef = ref as React.MutableRefObject<T | null>\n objectRef.current = node\n }\n }\n }\n}\n","import * as React from 'react'\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from 'react-hook-form'\nimport { cn, cva, devWarn } from '@refraction-ui/shared'\nimport { Slot } from './slot.js'\n\n/**\n * Form — RHF FormProvider wrapper.\n *\n * Spread the result of `useForm()` into <Form> so descendants can read the\n * form state via context. Renders no DOM of its own; consumers can place a\n * <form onSubmit={form.handleSubmit(...)}> inside.\n */\nconst Form = FormProvider\n\n// -----------------------------------------------------------------------------\n// Field context — bridges <FormField> and the inner Form* primitives.\n// -----------------------------------------------------------------------------\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue | undefined>(\n undefined,\n)\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue | undefined>(\n undefined,\n)\n\n/**\n * FormField — connects a named field to RHF's Controller and provides\n * field-name context to the descendants (FormLabel, FormControl, FormMessage).\n */\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(props: ControllerProps<TFieldValues, TName>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\n/**\n * useFormField — read-only access to the current field context.\n *\n * Returns the per-field id collection plus the live RHF error state. Useful\n * when building custom form controls that want the same wiring as FormControl.\n */\nfunction useFormField() {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const formContext = useFormContext()\n // useFormState subscribes to the specific field's error state, which keeps\n // re-renders narrow and works correctly with RHF v7 lazy subscriptions.\n const { errors } = useFormState({\n control: formContext?.control,\n name: fieldContext?.name as never,\n exact: true,\n })\n\n if (!fieldContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-field',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormField>. The missing FormFieldContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormField>')\n }\n if (!itemContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-item',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormItem>. The missing FormItemContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormItem>')\n }\n\n const { id } = itemContext\n const error = getNestedError(errors, fieldContext.name)\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n error,\n invalid: Boolean(error),\n }\n}\n\n// Walks a dot/bracket path through RHF's errors object. Mirrors the path\n// semantics of FieldPath without pulling in lodash.get.\nfunction getNestedError(\n errors: Record<string, unknown> | undefined,\n name: string,\n): { message?: string; type?: string } | undefined {\n if (!errors) return undefined\n const segments = name.replace(/\\[(\\w+)\\]/g, '.$1').split('.')\n let cursor: unknown = errors\n for (const seg of segments) {\n if (cursor && typeof cursor === 'object' && seg in (cursor as object)) {\n cursor = (cursor as Record<string, unknown>)[seg]\n } else {\n return undefined\n }\n }\n return cursor as { message?: string; type?: string } | undefined\n}\n\n// -----------------------------------------------------------------------------\n// FormItem — emits a stable id used by Label/Control/Description/Message.\n// -----------------------------------------------------------------------------\n\nconst formItemVariants = cva({ base: 'space-y-2' })\n\ninterface FormItemProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nconst FormItem = React.forwardRef<HTMLDivElement, FormItemProps>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(formItemVariants(), className)} {...props} />\n </FormItemContext.Provider>\n )\n },\n)\nFormItem.displayName = 'FormItem'\n\n// -----------------------------------------------------------------------------\n// FormLabel\n// -----------------------------------------------------------------------------\n\nconst formLabelVariants = cva({\n base: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n variants: {\n invalid: {\n true: 'text-destructive',\n false: '',\n },\n },\n defaultVariants: {\n invalid: 'false',\n },\n})\n\ninterface FormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {}\n\nconst FormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(\n ({ className, ...props }, ref) => {\n const { invalid, formItemId } = useFormField()\n return (\n <label\n ref={ref}\n htmlFor={formItemId}\n data-invalid={invalid ? '' : undefined}\n className={cn(formLabelVariants({ invalid: invalid ? 'true' : 'false' }), className)}\n {...props}\n />\n )\n },\n)\nFormLabel.displayName = 'FormLabel'\n\n// -----------------------------------------------------------------------------\n// FormControl — Slot that injects id/aria-describedby/aria-invalid.\n// -----------------------------------------------------------------------------\n\ninterface FormControlProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nconst FormControl = React.forwardRef<HTMLElement, FormControlProps>(\n ({ ...props }, ref) => {\n const { invalid, formItemId, formDescriptionId, formMessageId } =\n useFormField()\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n invalid\n ? `${formDescriptionId} ${formMessageId}`\n : formDescriptionId\n }\n aria-invalid={invalid || undefined}\n {...props}\n />\n )\n },\n)\nFormControl.displayName = 'FormControl'\n\n// -----------------------------------------------------------------------------\n// FormDescription\n// -----------------------------------------------------------------------------\n\ninterface FormDescriptionProps\n extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n FormDescriptionProps\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = 'FormDescription'\n\n// -----------------------------------------------------------------------------\n// FormMessage\n// -----------------------------------------------------------------------------\n\ninterface FormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(\n ({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error?.message ? String(error.message) : children\n if (!body) return null\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn('text-sm font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n )\n },\n)\nFormMessage.displayName = 'FormMessage'\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n formItemVariants,\n formLabelVariants,\n}\n\nexport type {\n FormItemProps,\n FormLabelProps,\n FormControlProps,\n FormDescriptionProps,\n FormMessageProps,\n}\n"]}
1
+ {"version":3,"sources":["../../shared/src/cn.ts","../../shared/src/cva.ts","../../shared/src/dev-feedback.ts","../../react-slot/src/slot.tsx","../../react-form/src/form.tsx"],"names":["React","Slot","FormProvider","React2","Controller","useFormContext","useFormState","FormItem","jsx","FormLabel","FormControl","FormDescription","FormMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,MAAM,MAAA,EAAiD;AACrE,EAAA,MAAM,UAAoB,EAAA;AAE1B,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,IAAI,CAAC,KAAA,EAAO;AAEZ,IAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,MAAA,OAAA,CAAQ,KAAK,K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;AAGV,EAAA;AACF;AASA,IAAM,eAAA,GAAwBL,6BAG5B,SAASQ,gBAAAA,CAAgB,EAAE,SAAA,EAAW,GAAG,KAAA,EAAA,EAAS,GAAA,EAAK;AACvD,EAAA,MAAM,EAAE,iBAAA,EAAA,GAAsB,YAAA,EAAA;AAC9B,EAAA,uBACEH,cAAA;AAAC,IAAA,GAAA;AAAA,IAAA;AACC,MAAA,GAAA;MACA,EAAA,EAAI,iBAAA;MACJ,SAAA,EAAW,EAAA,CAAG,iCAAiC,SAAS,CAAA;MACvD,GAAG;AAAA;AAAA,GAAA;AAGV,CAAC;AAQD,IAAM,WAAA,GAAoBL,iBAAA,CAAA,UAAA;AACxB,EAAA,SAASS,aAAY,EAAE,SAAA,EAAW,UAAU,GAAG,KAAA,IAAS,GAAA,EAAK;AAC3D,IAAA,MAAM,EAAE,KAAA,EAAO,aAAA,EAAA,GAAkB,YAAA,EAAA;AACjC,IAAA,MAAM,OAAO,KAAA,EAAO,OAAA,GAAU,MAAA,CAAO,KAAA,CAAM,OAAO,CAAA,GAAI,QAAA;AACtD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,IAAA,uBACEJ,cAAA;AAAC,MAAA,GAAA;AAAA,MAAA;AACC,QAAA,GAAA;QACA,EAAA,EAAI,aAAA;QACJ,SAAA,EAAW,EAAA,CAAG,wCAAwC,SAAS,CAAA;QAC9D,GAAG,KAAA;QAEH,QAAA,EAAA;AAAA;AAAA,KAAA;AAGP,EAAA;AACF","file":"form.cjs","sourcesContent":["/**\n * Lightweight class name utility — our own implementation.\n * Handles conditional classes, arrays, and falsy values.\n * No external dependencies (no clsx, no tailwind-merge).\n *\n * For Tailwind class conflict resolution (e.g., 'p-2 p-4' → 'p-4'),\n * consumers can use @refraction-ui/tailwind-config which provides\n * a tw-merge-aware variant of this function.\n */\n\ntype ClassValue = string | number | boolean | undefined | null | ClassValue[]\ntype ClassRecord = Record<string, boolean | undefined | null>\n\nexport function cn(...inputs: Array<ClassValue | ClassRecord>): string {\n const classes: string[] = []\n\n for (const input of inputs) {\n if (!input) continue\n\n if (typeof input === 'string') {\n classes.push(input)\n } else if (typeof input === 'number') {\n classes.push(String(input))\n } else if (Array.isArray(input)) {\n const nested = cn(...input)\n if (nested) classes.push(nested)\n } else if (typeof input === 'object') {\n for (const [key, value] of Object.entries(input)) {\n if (value) classes.push(key)\n }\n }\n }\n\n return classes.join(' ')\n}\n","/**\n * Lightweight class-variance-authority alternative — zero dependencies.\n * Creates variant-driven class name functions for components.\n */\n\ninterface VariantConfig {\n [variant: string]: Record<string, string>\n}\n\ninterface CVAConfig<V extends VariantConfig> {\n base?: string\n variants?: V\n defaultVariants?: {\n [K in keyof V]?: keyof V[K]\n }\n compoundVariants?: Array<\n {\n [K in keyof V]?: keyof V[K]\n } & { class: string }\n >\n}\n\ntype VariantProps<V extends VariantConfig> = {\n [K in keyof V]?: keyof V[K]\n}\n\nexport function cva<V extends VariantConfig>(config: CVAConfig<V>) {\n return (props?: VariantProps<V> & { className?: string }): string => {\n const classes: string[] = []\n\n if (config.base) {\n classes.push(config.base)\n }\n\n if (config.variants) {\n for (const [variantKey, variantOptions] of Object.entries(config.variants)) {\n const selectedValue =\n (props as Record<string, unknown> | undefined)?.[variantKey] ??\n config.defaultVariants?.[variantKey]\n\n if (selectedValue != null) {\n const variantClass = (variantOptions as Record<string, string>)[\n selectedValue as string\n ]\n if (variantClass) {\n classes.push(variantClass)\n }\n }\n }\n }\n\n if (config.compoundVariants) {\n for (const compound of config.compoundVariants) {\n const { class: compoundClass, ...conditions } = compound\n let matches = true\n\n for (const [key, value] of Object.entries(conditions)) {\n const propValue =\n (props as Record<string, unknown>)?.[key] ??\n config.defaultVariants?.[key]\n if (propValue !== value) {\n matches = false\n break\n }\n }\n\n if (matches) {\n classes.push(compoundClass as string)\n }\n }\n }\n\n if (props?.className) {\n classes.push(props.className)\n }\n\n return classes.filter(Boolean).join(' ')\n }\n}\n","/**\n * dev-feedback — zero-dependency `devWarn` / `devError` primitives.\n *\n * Design constraints (epic #247, issue #248):\n * - Guarded by `process.env.NODE_ENV !== 'production'` so production bundlers\n * dead-code-strip every call (the guard is a static string compare that\n * minifiers fold to `false` in prod builds).\n * - Warn-once dedupe per `code` — a footgun is reported once, not on every\n * render.\n * - NO import of `@refraction-ui/logger` (no hard dependency on the telemetry\n * lib). Forwarding to a telemetry sink happens ONLY if the consumer\n * explicitly injects one (dependency inversion, never an import).\n */\n\n/**\n * Minimal structural shape of the record a telemetry sink consumes. This is a\n * deliberate structural mirror of `@refraction-ui/logger`'s `LogRecord` — it is\n * NOT imported, so `@refraction-ui/shared` keeps zero dependency on the\n * telemetry lib. A consumer that wires the real logger sink satisfies this\n * shape structurally.\n */\nexport interface DevFeedbackRecord {\n level: 'warn' | 'error'\n message: string\n timestamp: number\n /** Structured detail — the library-origin envelope lives here. */\n context: Record<string, unknown>\n}\n\n/**\n * The narrow contract a consumer-injected telemetry sink must satisfy. Kept\n * intentionally minimal and structural so the real `TelemetrySink` from\n * `@refraction-ui/logger` is assignable WITHOUT shared importing the logger.\n */\nexport interface DevFeedbackSink {\n /** Receive a single dev-feedback record. Must never throw to the caller. */\n log(record: DevFeedbackRecord): void\n}\n\n/**\n * Minimal ambient view of `process.env` so we can read `NODE_ENV` WITHOUT\n * pulling `@types/node` into this zero-dependency package. Accessed defensively\n * (the `typeof process === 'undefined'` guard) so this is safe in browsers too.\n */\ndeclare const process:\n | { env?: { NODE_ENV?: string } }\n | undefined\n\n/** Per-code dedupe set — module-scoped so it survives across calls. */\nconst seen = new Set<string>()\n\n/**\n * Optional, consumer-injected sink. `null` until a consumer explicitly wires\n * one via {@link setDevFeedbackSink}. Nothing phones home implicitly.\n */\nlet injectedSink: DevFeedbackSink | null = null\n\n/**\n * Wire an optional telemetry sink that {@link devWarn} / {@link devError}\n * forward to (in addition to the console). Inversion of control: the consumer\n * owns the sink; this package never imports it. Pass `null` to unwire.\n *\n * Forwarding still only happens in non-production (the calls themselves are\n * stripped in prod), and still respects warn-once dedupe.\n */\nexport function setDevFeedbackSink(sink: DevFeedbackSink | null): void {\n injectedSink = sink\n}\n\n/** Test-only / consumer-only escape hatch to reset warn-once dedupe state. */\nexport function resetDevFeedback(): void {\n seen.clear()\n}\n\nfunction isDev(): boolean {\n // String compare (not a negated truthiness) so bundlers can statically fold\n // `process.env.NODE_ENV` and strip the whole branch in production builds.\n return (\n typeof process === 'undefined' ||\n process.env?.NODE_ENV !== 'production'\n )\n}\n\nfunction emit(\n level: 'warn' | 'error',\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n if (!isDev()) return\n\n // Warn-once dedupe, keyed by (level, code) so an error and a warning sharing\n // a code are not collapsed into one.\n const key = `${level}:${code}`\n if (seen.has(key)) return\n seen.add(key)\n\n const text = `[refraction-ui] ${code}: ${message}`\n\n if (level === 'error') {\n console.error(text, detail ?? '')\n } else {\n console.warn(text, detail ?? '')\n }\n\n // Forward to the consumer-injected sink ONLY if one was explicitly wired.\n if (injectedSink) {\n const record: DevFeedbackRecord = {\n level,\n message: `${code}: ${message}`,\n timestamp: Date.now(),\n context: { code, ...(detail ?? {}) },\n }\n try {\n injectedSink.log(record)\n } catch {\n // A broken sink must never break the consumer app.\n }\n }\n}\n\n/**\n * Emit a development-only warning for a refraction-ui footgun.\n *\n * @param code Stable, greppable identifier (e.g. `'react/no-controlled-prop'`).\n * @param message Human-readable explanation.\n * @param detail Optional structured detail (forwarded to an injected sink).\n *\n * Stripped entirely in production. Warned at most once per `code`.\n */\nexport function devWarn(\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n emit('warn', code, message, detail)\n}\n\n/**\n * Emit a development-only error for a refraction-ui misuse / invariant break.\n *\n * @param code Stable, greppable identifier.\n * @param message Human-readable explanation.\n * @param detail Optional structured detail (forwarded to an injected sink).\n *\n * Stripped entirely in production. Reported at most once per `code`.\n */\nexport function devError(\n code: string,\n message: string,\n detail?: Record<string, unknown>,\n): void {\n emit('error', code, message, detail)\n}\n","import * as React from 'react'\n\n/**\n * Minimal Slot implementation — the shared `asChild` primitive.\n *\n * Why not @radix-ui/react-slot? Per package policy, no external runtime deps\n * are allowed in @refraction-ui/* packages. This Slot does the small amount\n * of work we actually need:\n * - Forwards a single React child\n * - Merges incoming props onto that child (event handlers are chained,\n * className is concatenated, style is shallow-merged)\n * - Merges refs (callback refs and ref objects)\n *\n * It is intentionally simpler than Radix Slot — no <Slottable/>, no asChild\n * recursion. `asChild` components render exactly one child element, which is\n * all we need here. Non-element children (text, arrays, null) render nothing.\n */\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>(function Slot(\n props,\n forwardedRef,\n) {\n const { children, ...slotProps } = props\n\n if (!React.isValidElement(children)) {\n return null\n }\n\n // The child element's existing props\n const childProps = (children.props ?? {}) as Record<string, unknown>\n\n const mergedProps = mergeProps(slotProps as Record<string, unknown>, childProps)\n\n // Forward + merge refs. In React 19 `ref` is a regular prop on `props`; in\n // React 18 it's hoisted onto the element. Prefer the prop and only fall back\n // to the element field if `props.ref` truly wasn't there — that fallback path\n // is React 18 only.\n let childRef: React.Ref<unknown> | undefined = childProps.ref as\n | React.Ref<unknown>\n | undefined\n if (childRef === undefined && !('ref' in (childProps as object))) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n childRef = (children as any).ref as React.Ref<unknown> | undefined\n }\n const mergedRef = composeRefs(forwardedRef as React.Ref<unknown>, childRef)\n\n return React.cloneElement(\n children as React.ReactElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { ...mergedProps, ref: mergedRef } as any,\n )\n})\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps }\n\n for (const key of Object.keys(childProps)) {\n const slotValue = slotProps[key]\n const childValue = childProps[key]\n\n // Chain event handlers: child's handler runs after slot's\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function' && typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n const child = childValue as (...a: unknown[]) => unknown\n const slot = slotValue as (...a: unknown[]) => unknown\n child(...args)\n slot(...args)\n }\n } else if (key === 'className') {\n merged[key] = [slotValue, childValue].filter(Boolean).join(' ')\n } else if (key === 'style') {\n merged[key] = { ...(slotValue as object), ...(childValue as object) }\n } else if (childValue !== undefined) {\n // Child wins for non-event, non-merged props\n merged[key] = childValue\n }\n }\n\n return merged\n}\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\nfunction composeRefs<T>(...refs: Array<PossibleRef<T>>): React.RefCallback<T> {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref != null) {\n const objectRef = ref as React.MutableRefObject<T | null>\n objectRef.current = node\n }\n }\n }\n}\n","import * as React from 'react'\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from 'react-hook-form'\nimport { cn, cva, devWarn } from '@refraction-ui/shared'\nimport { Slot } from '@refraction-ui/react-slot'\n\n/**\n * Form — RHF FormProvider wrapper.\n *\n * Spread the result of `useForm()` into <Form> so descendants can read the\n * form state via context. Renders no DOM of its own; consumers can place a\n * <form onSubmit={form.handleSubmit(...)}> inside.\n */\nconst Form = FormProvider\n\n// -----------------------------------------------------------------------------\n// Field context — bridges <FormField> and the inner Form* primitives.\n// -----------------------------------------------------------------------------\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue | undefined>(\n undefined,\n)\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue | undefined>(\n undefined,\n)\n\n/**\n * FormField — connects a named field to RHF's Controller and provides\n * field-name context to the descendants (FormLabel, FormControl, FormMessage).\n */\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(props: ControllerProps<TFieldValues, TName>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\n/**\n * useFormField — read-only access to the current field context.\n *\n * Returns the per-field id collection plus the live RHF error state. Useful\n * when building custom form controls that want the same wiring as FormControl.\n */\nfunction useFormField() {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const formContext = useFormContext()\n // useFormState subscribes to the specific field's error state, which keeps\n // re-renders narrow and works correctly with RHF v7 lazy subscriptions.\n const { errors } = useFormState({\n control: formContext?.control,\n name: fieldContext?.name as never,\n exact: true,\n })\n\n if (!fieldContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-field',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormField>. The missing FormFieldContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormField>')\n }\n if (!itemContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-item',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormItem>. The missing FormItemContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormItem>')\n }\n\n const { id } = itemContext\n const error = getNestedError(errors, fieldContext.name)\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n error,\n invalid: Boolean(error),\n }\n}\n\n// Walks a dot/bracket path through RHF's errors object. Mirrors the path\n// semantics of FieldPath without pulling in lodash.get.\nfunction getNestedError(\n errors: Record<string, unknown> | undefined,\n name: string,\n): { message?: string; type?: string } | undefined {\n if (!errors) return undefined\n const segments = name.replace(/\\[(\\w+)\\]/g, '.$1').split('.')\n let cursor: unknown = errors\n for (const seg of segments) {\n if (cursor && typeof cursor === 'object' && seg in (cursor as object)) {\n cursor = (cursor as Record<string, unknown>)[seg]\n } else {\n return undefined\n }\n }\n return cursor as { message?: string; type?: string } | undefined\n}\n\n// -----------------------------------------------------------------------------\n// FormItem — emits a stable id used by Label/Control/Description/Message.\n// -----------------------------------------------------------------------------\n\nconst formItemVariants = cva({ base: 'space-y-2' })\n\ninterface FormItemProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nconst FormItem = React.forwardRef<HTMLDivElement, FormItemProps>(\n function FormItem({ className, ...props }, ref) {\n const id = React.useId()\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(formItemVariants(), className)} {...props} />\n </FormItemContext.Provider>\n )\n },\n)\n\n// -----------------------------------------------------------------------------\n// FormLabel\n// -----------------------------------------------------------------------------\n\nconst formLabelVariants = cva({\n base: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n variants: {\n invalid: {\n true: 'text-destructive',\n false: '',\n },\n },\n defaultVariants: {\n invalid: 'false',\n },\n})\n\ninterface FormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {}\n\nconst FormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(\n function FormLabel({ className, ...props }, ref) {\n const { invalid, formItemId } = useFormField()\n return (\n <label\n ref={ref}\n htmlFor={formItemId}\n data-invalid={invalid ? '' : undefined}\n className={cn(formLabelVariants({ invalid: invalid ? 'true' : 'false' }), className)}\n {...props}\n />\n )\n },\n)\n\n// -----------------------------------------------------------------------------\n// FormControl — Slot that injects id/aria-describedby/aria-invalid.\n// -----------------------------------------------------------------------------\n\ninterface FormControlProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nconst FormControl = React.forwardRef<HTMLElement, FormControlProps>(\n function FormControl({ ...props }, ref) {\n const { invalid, formItemId, formDescriptionId, formMessageId } =\n useFormField()\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n invalid\n ? `${formDescriptionId} ${formMessageId}`\n : formDescriptionId\n }\n aria-invalid={invalid || undefined}\n {...props}\n />\n )\n },\n)\n\n// -----------------------------------------------------------------------------\n// FormDescription\n// -----------------------------------------------------------------------------\n\ninterface FormDescriptionProps\n extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n FormDescriptionProps\n>(function FormDescription({ className, ...props }, ref) {\n const { formDescriptionId } = useFormField()\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n})\n\n// -----------------------------------------------------------------------------\n// FormMessage\n// -----------------------------------------------------------------------------\n\ninterface FormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(\n function FormMessage({ className, children, ...props }, ref) {\n const { error, formMessageId } = useFormField()\n const body = error?.message ? String(error.message) : children\n if (!body) return null\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn('text-sm font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n )\n },\n)\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n formItemVariants,\n formLabelVariants,\n}\n\nexport type {\n FormItemProps,\n FormLabelProps,\n FormControlProps,\n FormDescriptionProps,\n FormMessageProps,\n}\n"]}
package/dist/form.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { cva, cn, devWarn } from './chunk-4A4BW3GR.js';
2
+ import { cva, cn, devWarn } from './chunk-Y2FNNAIL.js';
3
3
  import * as React2 from 'react';
4
4
  import { useFormContext, useFormState, FormProvider, Controller } from 'react-hook-form';
5
5
  export { Controller, FormProvider, useController, useForm, useFormContext, useFormState, useWatch } from 'react-hook-form';
@@ -23,7 +23,6 @@ var Slot = React2.forwardRef(function Slot2(props, forwardedRef) {
23
23
  { ...mergedProps, ref: mergedRef }
24
24
  );
25
25
  });
26
- Slot.displayName = "Slot";
27
26
  function mergeProps(slotProps, childProps) {
28
27
  const merged = { ...slotProps };
29
28
  for (const key of Object.keys(childProps)) {
@@ -118,12 +117,11 @@ function getNestedError(errors, name) {
118
117
  }
119
118
  var formItemVariants = cva({ base: "space-y-2" });
120
119
  var FormItem = React2.forwardRef(
121
- ({ className, ...props }, ref) => {
120
+ function FormItem2({ className, ...props }, ref) {
122
121
  const id = React2.useId();
123
122
  return /* @__PURE__ */ jsx(FormItemContext.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { ref, className: cn(formItemVariants(), className), ...props }) });
124
123
  }
125
124
  );
126
- FormItem.displayName = "FormItem";
127
125
  var formLabelVariants = cva({
128
126
  base: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
129
127
  variants: {
@@ -137,7 +135,7 @@ var formLabelVariants = cva({
137
135
  }
138
136
  });
139
137
  var FormLabel = React2.forwardRef(
140
- ({ className, ...props }, ref) => {
138
+ function FormLabel2({ className, ...props }, ref) {
141
139
  const { invalid, formItemId } = useFormField();
142
140
  return /* @__PURE__ */ jsx(
143
141
  "label",
@@ -151,9 +149,8 @@ var FormLabel = React2.forwardRef(
151
149
  );
152
150
  }
153
151
  );
154
- FormLabel.displayName = "FormLabel";
155
152
  var FormControl = React2.forwardRef(
156
- ({ ...props }, ref) => {
153
+ function FormControl2({ ...props }, ref) {
157
154
  const { invalid, formItemId, formDescriptionId, formMessageId } = useFormField();
158
155
  return /* @__PURE__ */ jsx(
159
156
  Slot,
@@ -167,8 +164,7 @@ var FormControl = React2.forwardRef(
167
164
  );
168
165
  }
169
166
  );
170
- FormControl.displayName = "FormControl";
171
- var FormDescription = React2.forwardRef(({ className, ...props }, ref) => {
167
+ var FormDescription = React2.forwardRef(function FormDescription2({ className, ...props }, ref) {
172
168
  const { formDescriptionId } = useFormField();
173
169
  return /* @__PURE__ */ jsx(
174
170
  "p",
@@ -180,9 +176,8 @@ var FormDescription = React2.forwardRef(({ className, ...props }, ref) => {
180
176
  }
181
177
  );
182
178
  });
183
- FormDescription.displayName = "FormDescription";
184
179
  var FormMessage = React2.forwardRef(
185
- ({ className, children, ...props }, ref) => {
180
+ function FormMessage2({ className, children, ...props }, ref) {
186
181
  const { error, formMessageId } = useFormField();
187
182
  const body = error?.message ? String(error.message) : children;
188
183
  if (!body) return null;
@@ -198,7 +193,6 @@ var FormMessage = React2.forwardRef(
198
193
  );
199
194
  }
200
195
  );
201
- FormMessage.displayName = "FormMessage";
202
196
 
203
197
  export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, Slot, formItemVariants, formLabelVariants, useFormField };
204
198
  //# sourceMappingURL=form.js.map
package/dist/form.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../react-form/src/slot.tsx","../../react-form/src/form.tsx"],"names":["Slot"],"mappings":";;;;;;AAqBO,IAAM,IAAA,GAAa,MAAA,CAAA,UAAA,CAAmC,SAASA,KAAAA,CACpE,OACA,YAAA,EACA;AACA,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAA,GAAc,KAAA;AAEnC,EAAA,IAAI,CAAO,MAAA,CAAA,cAAA,CAAe,QAAQ,CAAA,EAAG;AACnC,IAAA,OAAO,IAAA;AACT,EAAA;AAGA,EAAA,MAAM,UAAA,GAAc,QAAA,CAAS,KAAA,IAAS,EAAA;AAEtC,EAAA,MAAM,WAAA,GAAc,UAAA,CAAW,SAAA,EAAsC,UAAU,CAAA;AAM/E,EAAA,IAAI,WAA2C,UAAA,CAAW,GAAA;AAG1D,EAAA,IAAI,QAAA,KAAa,MAAA,IAAa,EAAE,KAAA,IAAU,UAAA,CAAA,EAAwB;AAEhE,IAAA,QAAA,GAAY,QAAA,CAAiB,GAAA;AAC/B,EAAA;AACA,EAAA,MAAM,SAAA,GAAY,WAAA,CAAY,YAAA,EAAoC,QAAQ,CAAA;AAE1E,EAAA,OAAa,MAAA,CAAA,YAAA;AACX,IAAA,QAAA;;IAEA,EAAE,GAAG,WAAA,EAAa,GAAA,EAAK,SAAA;AAAU,GAAA;AAErC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Why not @radix-ui/react-slot? Per package policy, no external runtime deps\n * are allowed in @refraction-ui/* packages. This Slot does the small amount\n * of work we actually need:\n * - Forwards a single React child\n * - Merges incoming props onto that child (event handlers are chained,\n * className is concatenated, style is shallow-merged)\n * - Merges refs (callback refs and ref objects)\n *\n * It is intentionally simpler than Radix Slot — no <Slottable/>, no asChild\n * recursion. FormControl renders exactly one child input/textarea/etc., which\n * is all we need here.\n */\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>(function Slot(\n props,\n forwardedRef,\n) {\n const { children, ...slotProps } = props\n\n if (!React.isValidElement(children)) {\n return null\n }\n\n // The child element's existing props\n const childProps = (children.props ?? {}) as Record<string, unknown>\n\n const mergedProps = mergeProps(slotProps as Record<string, unknown>, childProps)\n\n // Forward + merge refs. In React 19 `ref` is a regular prop on `props`; in\n // React 18 it's hoisted onto the element. Prefer the prop and only fall back\n // to the element field if `props.ref` truly wasn't there — that fallback path\n // is React 18 only.\n let childRef: React.Ref<unknown> | undefined = childProps.ref as\n | React.Ref<unknown>\n | undefined\n if (childRef === undefined && !('ref' in (childProps as object))) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n childRef = (children as any).ref as React.Ref<unknown> | undefined\n }\n const mergedRef = composeRefs(forwardedRef as React.Ref<unknown>, childRef)\n\n return React.cloneElement(\n children as React.ReactElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { ...mergedProps, ref: mergedRef } as any,\n )\n})\n\nSlot.displayName = 'Slot'\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps }\n\n for (const key of Object.keys(childProps)) {\n const slotValue = slotProps[key]\n const childValue = childProps[key]\n\n // Chain event handlers: child's handler runs after slot's\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function' && typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n const child = childValue as (...a: unknown[]) => unknown\n const slot = slotValue as (...a: unknown[]) => unknown\n child(...args)\n slot(...args)\n }\n } else if (key === 'className') {\n merged[key] = [slotValue, childValue].filter(Boolean).join(' ')\n } else if (key === 'style') {\n merged[key] = { ...(slotValue as object), ...(childValue as object) }\n } else if (childValue !== undefined) {\n // Child wins for non-event, non-merged props\n merged[key] = childValue\n }\n }\n\n return merged\n}\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\nfunction composeRefs<T>(...refs: Array<PossibleRef<T>>): React.RefCallback<T> {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref != null) {\n const objectRef = ref as React.MutableRefObject<T | null>\n objectRef.current = node\n }\n }\n }\n}\n","import * as React from 'react'\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from 'react-hook-form'\nimport { cn, cva, devWarn } from '@refraction-ui/shared'\nimport { Slot } from './slot.js'\n\n/**\n * Form — RHF FormProvider wrapper.\n *\n * Spread the result of `useForm()` into <Form> so descendants can read the\n * form state via context. Renders no DOM of its own; consumers can place a\n * <form onSubmit={form.handleSubmit(...)}> inside.\n */\nconst Form = FormProvider\n\n// -----------------------------------------------------------------------------\n// Field context — bridges <FormField> and the inner Form* primitives.\n// -----------------------------------------------------------------------------\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue | undefined>(\n undefined,\n)\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue | undefined>(\n undefined,\n)\n\n/**\n * FormField — connects a named field to RHF's Controller and provides\n * field-name context to the descendants (FormLabel, FormControl, FormMessage).\n */\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(props: ControllerProps<TFieldValues, TName>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\n/**\n * useFormField — read-only access to the current field context.\n *\n * Returns the per-field id collection plus the live RHF error state. Useful\n * when building custom form controls that want the same wiring as FormControl.\n */\nfunction useFormField() {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const formContext = useFormContext()\n // useFormState subscribes to the specific field's error state, which keeps\n // re-renders narrow and works correctly with RHF v7 lazy subscriptions.\n const { errors } = useFormState({\n control: formContext?.control,\n name: fieldContext?.name as never,\n exact: true,\n })\n\n if (!fieldContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-field',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormField>. The missing FormFieldContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormField>')\n }\n if (!itemContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-item',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormItem>. The missing FormItemContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormItem>')\n }\n\n const { id } = itemContext\n const error = getNestedError(errors, fieldContext.name)\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n error,\n invalid: Boolean(error),\n }\n}\n\n// Walks a dot/bracket path through RHF's errors object. Mirrors the path\n// semantics of FieldPath without pulling in lodash.get.\nfunction getNestedError(\n errors: Record<string, unknown> | undefined,\n name: string,\n): { message?: string; type?: string } | undefined {\n if (!errors) return undefined\n const segments = name.replace(/\\[(\\w+)\\]/g, '.$1').split('.')\n let cursor: unknown = errors\n for (const seg of segments) {\n if (cursor && typeof cursor === 'object' && seg in (cursor as object)) {\n cursor = (cursor as Record<string, unknown>)[seg]\n } else {\n return undefined\n }\n }\n return cursor as { message?: string; type?: string } | undefined\n}\n\n// -----------------------------------------------------------------------------\n// FormItem — emits a stable id used by Label/Control/Description/Message.\n// -----------------------------------------------------------------------------\n\nconst formItemVariants = cva({ base: 'space-y-2' })\n\ninterface FormItemProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nconst FormItem = React.forwardRef<HTMLDivElement, FormItemProps>(\n ({ className, ...props }, ref) => {\n const id = React.useId()\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(formItemVariants(), className)} {...props} />\n </FormItemContext.Provider>\n )\n },\n)\nFormItem.displayName = 'FormItem'\n\n// -----------------------------------------------------------------------------\n// FormLabel\n// -----------------------------------------------------------------------------\n\nconst formLabelVariants = cva({\n base: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n variants: {\n invalid: {\n true: 'text-destructive',\n false: '',\n },\n },\n defaultVariants: {\n invalid: 'false',\n },\n})\n\ninterface FormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {}\n\nconst FormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(\n ({ className, ...props }, ref) => {\n const { invalid, formItemId } = useFormField()\n return (\n <label\n ref={ref}\n htmlFor={formItemId}\n data-invalid={invalid ? '' : undefined}\n className={cn(formLabelVariants({ invalid: invalid ? 'true' : 'false' }), className)}\n {...props}\n />\n )\n },\n)\nFormLabel.displayName = 'FormLabel'\n\n// -----------------------------------------------------------------------------\n// FormControl — Slot that injects id/aria-describedby/aria-invalid.\n// -----------------------------------------------------------------------------\n\ninterface FormControlProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nconst FormControl = React.forwardRef<HTMLElement, FormControlProps>(\n ({ ...props }, ref) => {\n const { invalid, formItemId, formDescriptionId, formMessageId } =\n useFormField()\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n invalid\n ? `${formDescriptionId} ${formMessageId}`\n : formDescriptionId\n }\n aria-invalid={invalid || undefined}\n {...props}\n />\n )\n },\n)\nFormControl.displayName = 'FormControl'\n\n// -----------------------------------------------------------------------------\n// FormDescription\n// -----------------------------------------------------------------------------\n\ninterface FormDescriptionProps\n extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n FormDescriptionProps\n>(({ className, ...props }, ref) => {\n const { formDescriptionId } = useFormField()\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n})\nFormDescription.displayName = 'FormDescription'\n\n// -----------------------------------------------------------------------------\n// FormMessage\n// -----------------------------------------------------------------------------\n\ninterface FormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(\n ({ className, children, ...props }, ref) => {\n const { error, formMessageId } = useFormField()\n const body = error?.message ? String(error.message) : children\n if (!body) return null\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn('text-sm font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n )\n },\n)\nFormMessage.displayName = 'FormMessage'\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n formItemVariants,\n formLabelVariants,\n}\n\nexport type {\n FormItemProps,\n FormLabelProps,\n FormControlProps,\n FormDescriptionProps,\n FormMessageProps,\n}\n"]}
1
+ {"version":3,"sources":["../../react-slot/src/slot.tsx","../../react-form/src/form.tsx"],"names":["React","Slot","FormItem","FormLabel","FormControl","FormDescription","FormMessage"],"mappings":";;;;;;AAqBO,IAAM,IAAA,GAAaA,MAAA,CAAA,UAAA,CAAmC,SAASC,KAAAA,CACpE,OACA,YAAA,EACA;AACA,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,SAAA,EAAA,GAAc,KAAA;AAEnC,EAAA,IAAI,CAAOD,MAAA,CAAA,cAAA,CAAe,QAAQ,CAAA,EAAG;AACnC,IAAA,OAAO,IAAA;AACT,EAAA;AAGA,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tD,IAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,IAAA,uBACE,GAAA;AAAC,MAAA,GAAA;AAAA,MAAA;AACC,QAAA,GAAA;QACA,EAAA,EAAI,aAAA;QACJ,SAAA,EAAW,EAAA,CAAG,wCAAwC,SAAS,CAAA;QAC9D,GAAG,KAAA;QAEH,QAAA,EAAA;AAAA;AAAA,KAAA;AAGP,EAAA;AACF","file":"form.js","sourcesContent":["import * as React from 'react'\n\n/**\n * Minimal Slot implementation — the shared `asChild` primitive.\n *\n * Why not @radix-ui/react-slot? Per package policy, no external runtime deps\n * are allowed in @refraction-ui/* packages. This Slot does the small amount\n * of work we actually need:\n * - Forwards a single React child\n * - Merges incoming props onto that child (event handlers are chained,\n * className is concatenated, style is shallow-merged)\n * - Merges refs (callback refs and ref objects)\n *\n * It is intentionally simpler than Radix Slot — no <Slottable/>, no asChild\n * recursion. `asChild` components render exactly one child element, which is\n * all we need here. Non-element children (text, arrays, null) render nothing.\n */\nexport interface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nexport const Slot = React.forwardRef<HTMLElement, SlotProps>(function Slot(\n props,\n forwardedRef,\n) {\n const { children, ...slotProps } = props\n\n if (!React.isValidElement(children)) {\n return null\n }\n\n // The child element's existing props\n const childProps = (children.props ?? {}) as Record<string, unknown>\n\n const mergedProps = mergeProps(slotProps as Record<string, unknown>, childProps)\n\n // Forward + merge refs. In React 19 `ref` is a regular prop on `props`; in\n // React 18 it's hoisted onto the element. Prefer the prop and only fall back\n // to the element field if `props.ref` truly wasn't there — that fallback path\n // is React 18 only.\n let childRef: React.Ref<unknown> | undefined = childProps.ref as\n | React.Ref<unknown>\n | undefined\n if (childRef === undefined && !('ref' in (childProps as object))) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n childRef = (children as any).ref as React.Ref<unknown> | undefined\n }\n const mergedRef = composeRefs(forwardedRef as React.Ref<unknown>, childRef)\n\n return React.cloneElement(\n children as React.ReactElement,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n { ...mergedProps, ref: mergedRef } as any,\n )\n})\n\nfunction mergeProps(\n slotProps: Record<string, unknown>,\n childProps: Record<string, unknown>,\n): Record<string, unknown> {\n const merged: Record<string, unknown> = { ...slotProps }\n\n for (const key of Object.keys(childProps)) {\n const slotValue = slotProps[key]\n const childValue = childProps[key]\n\n // Chain event handlers: child's handler runs after slot's\n if (/^on[A-Z]/.test(key) && typeof slotValue === 'function' && typeof childValue === 'function') {\n merged[key] = (...args: unknown[]) => {\n const child = childValue as (...a: unknown[]) => unknown\n const slot = slotValue as (...a: unknown[]) => unknown\n child(...args)\n slot(...args)\n }\n } else if (key === 'className') {\n merged[key] = [slotValue, childValue].filter(Boolean).join(' ')\n } else if (key === 'style') {\n merged[key] = { ...(slotValue as object), ...(childValue as object) }\n } else if (childValue !== undefined) {\n // Child wins for non-event, non-merged props\n merged[key] = childValue\n }\n }\n\n return merged\n}\n\ntype PossibleRef<T> = React.Ref<T> | undefined\n\nfunction composeRefs<T>(...refs: Array<PossibleRef<T>>): React.RefCallback<T> {\n return (node: T) => {\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(node)\n } else if (ref != null) {\n const objectRef = ref as React.MutableRefObject<T | null>\n objectRef.current = node\n }\n }\n }\n}\n","import * as React from 'react'\nimport {\n Controller,\n FormProvider,\n useFormContext,\n useFormState,\n type ControllerProps,\n type FieldPath,\n type FieldValues,\n} from 'react-hook-form'\nimport { cn, cva, devWarn } from '@refraction-ui/shared'\nimport { Slot } from '@refraction-ui/react-slot'\n\n/**\n * Form — RHF FormProvider wrapper.\n *\n * Spread the result of `useForm()` into <Form> so descendants can read the\n * form state via context. Renders no DOM of its own; consumers can place a\n * <form onSubmit={form.handleSubmit(...)}> inside.\n */\nconst Form = FormProvider\n\n// -----------------------------------------------------------------------------\n// Field context — bridges <FormField> and the inner Form* primitives.\n// -----------------------------------------------------------------------------\n\ntype FormFieldContextValue<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n> = {\n name: TName\n}\n\nconst FormFieldContext = React.createContext<FormFieldContextValue | undefined>(\n undefined,\n)\n\ntype FormItemContextValue = {\n id: string\n}\n\nconst FormItemContext = React.createContext<FormItemContextValue | undefined>(\n undefined,\n)\n\n/**\n * FormField — connects a named field to RHF's Controller and provides\n * field-name context to the descendants (FormLabel, FormControl, FormMessage).\n */\nfunction FormField<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,\n>(props: ControllerProps<TFieldValues, TName>) {\n return (\n <FormFieldContext.Provider value={{ name: props.name }}>\n <Controller {...props} />\n </FormFieldContext.Provider>\n )\n}\n\n/**\n * useFormField — read-only access to the current field context.\n *\n * Returns the per-field id collection plus the live RHF error state. Useful\n * when building custom form controls that want the same wiring as FormControl.\n */\nfunction useFormField() {\n const fieldContext = React.useContext(FormFieldContext)\n const itemContext = React.useContext(FormItemContext)\n const formContext = useFormContext()\n // useFormState subscribes to the specific field's error state, which keeps\n // re-renders narrow and works correctly with RHF v7 lazy subscriptions.\n const { errors } = useFormState({\n control: formContext?.control,\n name: fieldContext?.name as never,\n exact: true,\n })\n\n if (!fieldContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-field',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormField>. The missing FormFieldContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormField>')\n }\n if (!itemContext) {\n devWarn(\n 'react-form/use-form-field-outside-form-item',\n 'useFormField (via FormLabel/FormControl/FormDescription/FormMessage) must be used inside a <FormItem>. The missing FormItemContext makes this throw.',\n )\n throw new Error('useFormField must be used within a <FormItem>')\n }\n\n const { id } = itemContext\n const error = getNestedError(errors, fieldContext.name)\n\n return {\n id,\n name: fieldContext.name,\n formItemId: `${id}-form-item`,\n formDescriptionId: `${id}-form-item-description`,\n formMessageId: `${id}-form-item-message`,\n error,\n invalid: Boolean(error),\n }\n}\n\n// Walks a dot/bracket path through RHF's errors object. Mirrors the path\n// semantics of FieldPath without pulling in lodash.get.\nfunction getNestedError(\n errors: Record<string, unknown> | undefined,\n name: string,\n): { message?: string; type?: string } | undefined {\n if (!errors) return undefined\n const segments = name.replace(/\\[(\\w+)\\]/g, '.$1').split('.')\n let cursor: unknown = errors\n for (const seg of segments) {\n if (cursor && typeof cursor === 'object' && seg in (cursor as object)) {\n cursor = (cursor as Record<string, unknown>)[seg]\n } else {\n return undefined\n }\n }\n return cursor as { message?: string; type?: string } | undefined\n}\n\n// -----------------------------------------------------------------------------\n// FormItem — emits a stable id used by Label/Control/Description/Message.\n// -----------------------------------------------------------------------------\n\nconst formItemVariants = cva({ base: 'space-y-2' })\n\ninterface FormItemProps extends React.HTMLAttributes<HTMLDivElement> {}\n\nconst FormItem = React.forwardRef<HTMLDivElement, FormItemProps>(\n function FormItem({ className, ...props }, ref) {\n const id = React.useId()\n return (\n <FormItemContext.Provider value={{ id }}>\n <div ref={ref} className={cn(formItemVariants(), className)} {...props} />\n </FormItemContext.Provider>\n )\n },\n)\n\n// -----------------------------------------------------------------------------\n// FormLabel\n// -----------------------------------------------------------------------------\n\nconst formLabelVariants = cva({\n base: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',\n variants: {\n invalid: {\n true: 'text-destructive',\n false: '',\n },\n },\n defaultVariants: {\n invalid: 'false',\n },\n})\n\ninterface FormLabelProps extends React.LabelHTMLAttributes<HTMLLabelElement> {}\n\nconst FormLabel = React.forwardRef<HTMLLabelElement, FormLabelProps>(\n function FormLabel({ className, ...props }, ref) {\n const { invalid, formItemId } = useFormField()\n return (\n <label\n ref={ref}\n htmlFor={formItemId}\n data-invalid={invalid ? '' : undefined}\n className={cn(formLabelVariants({ invalid: invalid ? 'true' : 'false' }), className)}\n {...props}\n />\n )\n },\n)\n\n// -----------------------------------------------------------------------------\n// FormControl — Slot that injects id/aria-describedby/aria-invalid.\n// -----------------------------------------------------------------------------\n\ninterface FormControlProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode\n}\n\nconst FormControl = React.forwardRef<HTMLElement, FormControlProps>(\n function FormControl({ ...props }, ref) {\n const { invalid, formItemId, formDescriptionId, formMessageId } =\n useFormField()\n return (\n <Slot\n ref={ref}\n id={formItemId}\n aria-describedby={\n invalid\n ? `${formDescriptionId} ${formMessageId}`\n : formDescriptionId\n }\n aria-invalid={invalid || undefined}\n {...props}\n />\n )\n },\n)\n\n// -----------------------------------------------------------------------------\n// FormDescription\n// -----------------------------------------------------------------------------\n\ninterface FormDescriptionProps\n extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormDescription = React.forwardRef<\n HTMLParagraphElement,\n FormDescriptionProps\n>(function FormDescription({ className, ...props }, ref) {\n const { formDescriptionId } = useFormField()\n return (\n <p\n ref={ref}\n id={formDescriptionId}\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n})\n\n// -----------------------------------------------------------------------------\n// FormMessage\n// -----------------------------------------------------------------------------\n\ninterface FormMessageProps extends React.HTMLAttributes<HTMLParagraphElement> {}\n\nconst FormMessage = React.forwardRef<HTMLParagraphElement, FormMessageProps>(\n function FormMessage({ className, children, ...props }, ref) {\n const { error, formMessageId } = useFormField()\n const body = error?.message ? String(error.message) : children\n if (!body) return null\n return (\n <p\n ref={ref}\n id={formMessageId}\n className={cn('text-sm font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n )\n },\n)\n\nexport {\n Form,\n FormControl,\n FormDescription,\n FormField,\n FormItem,\n FormLabel,\n FormMessage,\n useFormField,\n formItemVariants,\n formLabelVariants,\n}\n\nexport type {\n FormItemProps,\n FormLabelProps,\n FormControlProps,\n FormDescriptionProps,\n FormMessageProps,\n}\n"]}