@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,609 @@
1
+ import {
2
+ cn,
3
+ cva,
4
+ devWarn,
5
+ generateId
6
+ } from "./chunk-ZF3OHCGV.js";
7
+
8
+ // ../react-combobox/dist/index.js
9
+ import * as React from "react";
10
+ import { createPortal } from "react-dom";
11
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
12
+ var defaultFilter = (option, query) => {
13
+ if (!query) return true;
14
+ return option.label.toLowerCase().includes(query.toLowerCase());
15
+ };
16
+ var comboboxTriggerVariants = cva({
17
+ base: "flex w-full items-center justify-between rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
18
+ variants: {
19
+ size: {
20
+ sm: "h-8 text-xs",
21
+ default: "h-9 text-sm",
22
+ lg: "h-10 text-base"
23
+ }
24
+ },
25
+ defaultVariants: {
26
+ size: "default"
27
+ }
28
+ });
29
+ var comboboxContentVariants = cva({
30
+ base: "relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95"
31
+ });
32
+ var comboboxInputVariants = cva({
33
+ base: "flex h-9 w-full rounded-md border-0 border-b bg-transparent px-3 py-2 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50"
34
+ });
35
+ var comboboxListVariants = cva({
36
+ base: "max-h-[300px] overflow-y-auto overflow-x-hidden p-1"
37
+ });
38
+ var comboboxItemVariants = cva({
39
+ base: "relative flex w-full cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
40
+ variants: {
41
+ selected: {
42
+ true: "bg-accent/50 font-medium",
43
+ false: ""
44
+ }
45
+ },
46
+ defaultVariants: {
47
+ selected: "false"
48
+ }
49
+ });
50
+ var comboboxEmptyVariants = cva({
51
+ base: "py-6 text-center text-sm text-muted-foreground"
52
+ });
53
+ var ComboboxContext = React.createContext(null);
54
+ function useComboboxContext() {
55
+ const ctx = React.useContext(ComboboxContext);
56
+ if (!ctx) {
57
+ devWarn(
58
+ "react-combobox/context-outside-provider",
59
+ "Combobox compound components (ComboboxInput/ComboboxContent/ComboboxItem/etc.) must be rendered inside a <Combobox>. The missing ComboboxContext makes this throw."
60
+ );
61
+ throw new Error("Combobox compound components must be used within <Combobox>");
62
+ }
63
+ return ctx;
64
+ }
65
+ function Combobox({
66
+ value: valueProp,
67
+ defaultValue,
68
+ onValueChange,
69
+ open: openProp,
70
+ defaultOpen = false,
71
+ onOpenChange,
72
+ options,
73
+ filter = defaultFilter,
74
+ disabled = false,
75
+ children
76
+ }) {
77
+ const isValueControlled = valueProp !== void 0;
78
+ const [internalValue, setInternalValue] = React.useState(defaultValue);
79
+ const value = isValueControlled ? valueProp : internalValue;
80
+ const isOpenControlled = openProp !== void 0;
81
+ const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
82
+ const open = isOpenControlled ? openProp : internalOpen;
83
+ const [query, setQuery] = React.useState("");
84
+ const [highlightedValue, setHighlightedValue] = React.useState(void 0);
85
+ const [registry, setRegistry] = React.useState([]);
86
+ const [visibleCount, setVisibleCount] = React.useState(0);
87
+ const idBaseRef = React.useRef(generateId("combobox"));
88
+ const idBase = idBaseRef.current;
89
+ const triggerRef = React.useRef(null);
90
+ const contentRef = React.useRef(null);
91
+ const inputRef = React.useRef(null);
92
+ const handleValueChange = React.useCallback(
93
+ (next) => {
94
+ if (!isValueControlled) setInternalValue(next);
95
+ onValueChange?.(next);
96
+ },
97
+ [isValueControlled, onValueChange]
98
+ );
99
+ const handleOpenChange = React.useCallback(
100
+ (next) => {
101
+ if (disabled && next) return;
102
+ if (!isOpenControlled) setInternalOpen(next);
103
+ onOpenChange?.(next);
104
+ if (!next) {
105
+ setQuery("");
106
+ setHighlightedValue(void 0);
107
+ }
108
+ },
109
+ [disabled, isOpenControlled, onOpenChange]
110
+ );
111
+ const registerItem = React.useCallback((item) => {
112
+ setRegistry((prev) => {
113
+ const existing = prev.findIndex((i) => i.id === item.id);
114
+ if (existing >= 0) {
115
+ const next = prev.slice();
116
+ next[existing] = item;
117
+ return next;
118
+ }
119
+ return [...prev, item];
120
+ });
121
+ }, []);
122
+ const unregisterItem = React.useCallback((id) => {
123
+ setRegistry((prev) => prev.filter((i) => i.id !== id));
124
+ }, []);
125
+ const itemMatchesQuery = React.useCallback(
126
+ (label, itemValue, itemDisabled) => {
127
+ return filter({ value: itemValue, label, disabled: itemDisabled }, query);
128
+ },
129
+ [filter, query]
130
+ );
131
+ const matches = React.useCallback(
132
+ (option) => {
133
+ return filter(
134
+ { value: option.value, label: option.label, disabled: option.disabled },
135
+ query
136
+ );
137
+ },
138
+ [filter, query]
139
+ );
140
+ const selectedLabel = React.useMemo(() => {
141
+ if (value === void 0) return void 0;
142
+ if (options) {
143
+ const opt = options.find((o) => o.value === value);
144
+ if (opt) return opt.label;
145
+ }
146
+ const reg = registry.find((r) => r.value === value);
147
+ return reg?.label;
148
+ }, [value, options, registry]);
149
+ const ids = React.useMemo(
150
+ () => ({
151
+ trigger: `${idBase}-trigger`,
152
+ content: `${idBase}-content`,
153
+ list: `${idBase}-list`,
154
+ input: `${idBase}-input`,
155
+ item: (v) => `${idBase}-item-${v}`
156
+ }),
157
+ [idBase]
158
+ );
159
+ React.useEffect(() => {
160
+ if (!open) return;
161
+ if (typeof document === "undefined") return;
162
+ const handler = (e) => {
163
+ const target = e.target;
164
+ if (!target) return;
165
+ if (contentRef.current?.contains(target)) return;
166
+ if (triggerRef.current?.contains(target)) return;
167
+ handleOpenChange(false);
168
+ };
169
+ document.addEventListener("mousedown", handler);
170
+ return () => document.removeEventListener("mousedown", handler);
171
+ }, [open, handleOpenChange]);
172
+ React.useEffect(() => {
173
+ if (!open) return;
174
+ if (highlightedValue !== void 0) return;
175
+ const candidates = registry.filter(
176
+ (r) => !r.disabled && itemMatchesQuery(r.label, r.value, r.disabled)
177
+ );
178
+ if (candidates.length === 0) return;
179
+ const selected = candidates.find((r) => r.value === value);
180
+ setHighlightedValue(selected ? selected.value : candidates[0].value);
181
+ }, [open, highlightedValue, registry, value, itemMatchesQuery]);
182
+ React.useEffect(() => {
183
+ if (!open) return;
184
+ const candidates = registry.filter(
185
+ (r) => !r.disabled && itemMatchesQuery(r.label, r.value, r.disabled)
186
+ );
187
+ if (candidates.length === 0) {
188
+ setHighlightedValue(void 0);
189
+ return;
190
+ }
191
+ if (highlightedValue === void 0 || !candidates.some((c) => c.value === highlightedValue)) {
192
+ setHighlightedValue(candidates[0].value);
193
+ }
194
+ }, [query, open, registry, itemMatchesQuery, highlightedValue]);
195
+ const ctx = React.useMemo(
196
+ () => ({
197
+ value,
198
+ onValueChange: handleValueChange,
199
+ open,
200
+ setOpen: handleOpenChange,
201
+ query,
202
+ setQuery,
203
+ highlightedValue,
204
+ setHighlightedValue,
205
+ registerItem,
206
+ unregisterItem,
207
+ matches,
208
+ itemMatchesQuery,
209
+ visibleCount,
210
+ setVisibleCount,
211
+ ids,
212
+ disabled,
213
+ options: options ?? [],
214
+ hasOptions: !!options,
215
+ filter,
216
+ selectedLabel,
217
+ triggerRef,
218
+ contentRef,
219
+ inputRef
220
+ }),
221
+ [
222
+ value,
223
+ handleValueChange,
224
+ open,
225
+ handleOpenChange,
226
+ query,
227
+ highlightedValue,
228
+ registerItem,
229
+ unregisterItem,
230
+ matches,
231
+ itemMatchesQuery,
232
+ visibleCount,
233
+ ids,
234
+ disabled,
235
+ options,
236
+ filter,
237
+ selectedLabel
238
+ ]
239
+ );
240
+ return /* @__PURE__ */ jsx(ComboboxContext.Provider, { value: ctx, children });
241
+ }
242
+ var ComboboxTrigger = React.forwardRef(function ComboboxTrigger2({ className, children, size = "default", placeholder = "Select\u2026", ...props }, forwardedRef) {
243
+ const ctx = useComboboxContext();
244
+ const { open, setOpen, disabled, ids, selectedLabel, triggerRef } = ctx;
245
+ const ref = React.useCallback(
246
+ (node) => {
247
+ triggerRef.current = node;
248
+ if (typeof forwardedRef === "function") forwardedRef(node);
249
+ else if (forwardedRef) forwardedRef.current = node;
250
+ },
251
+ [forwardedRef, triggerRef]
252
+ );
253
+ const handleClick = (e) => {
254
+ if (disabled) return;
255
+ setOpen(!open);
256
+ props.onClick?.(e);
257
+ };
258
+ const handleKeyDown = (e) => {
259
+ if (disabled) return;
260
+ if (e.key === "Enter" || e.key === " ") {
261
+ e.preventDefault();
262
+ setOpen(!open);
263
+ } else if (e.key === "Escape") {
264
+ if (open) {
265
+ e.preventDefault();
266
+ setOpen(false);
267
+ }
268
+ } else if ((e.key === "ArrowDown" || e.key === "ArrowUp") && !open) {
269
+ e.preventDefault();
270
+ setOpen(true);
271
+ }
272
+ props.onKeyDown?.(e);
273
+ };
274
+ const label = children ?? selectedLabel ?? placeholder;
275
+ const isPlaceholder = !children && selectedLabel === void 0;
276
+ return /* @__PURE__ */ jsxs(
277
+ "button",
278
+ {
279
+ ...props,
280
+ ref,
281
+ type: "button",
282
+ id: ids.trigger,
283
+ role: "combobox",
284
+ "aria-expanded": open,
285
+ "aria-controls": ids.content,
286
+ "aria-haspopup": "listbox",
287
+ "aria-disabled": disabled || void 0,
288
+ "data-state": open ? "open" : "closed",
289
+ "data-placeholder": isPlaceholder ? "" : void 0,
290
+ disabled,
291
+ className: cn(comboboxTriggerVariants({ size }), className),
292
+ onClick: handleClick,
293
+ onKeyDown: handleKeyDown,
294
+ children: [
295
+ /* @__PURE__ */ jsx("span", { className: cn("truncate", isPlaceholder && "text-muted-foreground"), children: label }),
296
+ /* @__PURE__ */ jsx(
297
+ "svg",
298
+ {
299
+ className: "h-4 w-4 opacity-50 shrink-0",
300
+ xmlns: "http://www.w3.org/2000/svg",
301
+ viewBox: "0 0 24 24",
302
+ fill: "none",
303
+ stroke: "currentColor",
304
+ strokeWidth: "2",
305
+ strokeLinecap: "round",
306
+ strokeLinejoin: "round",
307
+ "aria-hidden": "true",
308
+ children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" })
309
+ }
310
+ )
311
+ ]
312
+ }
313
+ );
314
+ });
315
+ var ComboboxContent = React.forwardRef(
316
+ function ComboboxContent2({ className, children, portal = true, ...props }, forwardedRef) {
317
+ const ctx = useComboboxContext();
318
+ const { open, ids, contentRef, hasOptions, options, inputRef } = ctx;
319
+ const ref = React.useCallback(
320
+ (node) => {
321
+ contentRef.current = node;
322
+ if (typeof forwardedRef === "function") forwardedRef(node);
323
+ else if (forwardedRef) forwardedRef.current = node;
324
+ },
325
+ [forwardedRef, contentRef]
326
+ );
327
+ React.useEffect(() => {
328
+ if (open) {
329
+ const t = setTimeout(() => inputRef.current?.focus(), 0);
330
+ return () => clearTimeout(t);
331
+ }
332
+ }, [open, inputRef]);
333
+ if (!open) return null;
334
+ const content = /* @__PURE__ */ jsx(
335
+ "div",
336
+ {
337
+ ...props,
338
+ ref,
339
+ id: ids.content,
340
+ "data-state": open ? "open" : "closed",
341
+ className: cn(comboboxContentVariants(), className),
342
+ children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
343
+ /* @__PURE__ */ jsx(ComboboxInput, {}),
344
+ /* @__PURE__ */ jsx(ComboboxList, { children: hasOptions ? options.map((opt) => /* @__PURE__ */ jsx(
345
+ ComboboxItem,
346
+ {
347
+ value: opt.value,
348
+ disabled: opt.disabled,
349
+ children: opt.label
350
+ },
351
+ opt.value
352
+ )) : null }),
353
+ /* @__PURE__ */ jsx(ComboboxEmpty, { children: "No results." })
354
+ ] })
355
+ }
356
+ );
357
+ if (portal && typeof document !== "undefined") {
358
+ return createPortal(content, document.body);
359
+ }
360
+ return content;
361
+ }
362
+ );
363
+ var ComboboxInput = React.forwardRef(
364
+ function ComboboxInput2({ className, onChange, onKeyDown, placeholder = "Search\u2026", ...props }, forwardedRef) {
365
+ const ctx = useComboboxContext();
366
+ const {
367
+ query,
368
+ setQuery,
369
+ ids,
370
+ open,
371
+ setOpen,
372
+ highlightedValue,
373
+ setHighlightedValue,
374
+ onValueChange,
375
+ itemMatchesQuery,
376
+ inputRef,
377
+ triggerRef
378
+ } = ctx;
379
+ const ref = React.useCallback(
380
+ (node) => {
381
+ inputRef.current = node;
382
+ if (typeof forwardedRef === "function") forwardedRef(node);
383
+ else if (forwardedRef) forwardedRef.current = node;
384
+ },
385
+ [forwardedRef, inputRef]
386
+ );
387
+ const handleChange = (e) => {
388
+ setQuery(e.target.value);
389
+ onChange?.(e);
390
+ };
391
+ const getCandidates = () => {
392
+ const root = ctx.contentRef.current;
393
+ if (!root) return [];
394
+ const els = Array.from(
395
+ root.querySelectorAll(
396
+ '[role="option"]:not([data-disabled]):not([data-hidden])'
397
+ )
398
+ );
399
+ return els.map((el) => ({
400
+ value: el.getAttribute("data-value") ?? "",
401
+ label: el.textContent ?? ""
402
+ }));
403
+ };
404
+ const moveHighlight = (delta) => {
405
+ const candidates = getCandidates();
406
+ if (candidates.length === 0) {
407
+ setHighlightedValue(void 0);
408
+ return;
409
+ }
410
+ const idx = candidates.findIndex((c) => c.value === highlightedValue);
411
+ let next;
412
+ if (idx === -1) {
413
+ next = delta > 0 ? 0 : candidates.length - 1;
414
+ } else {
415
+ next = (idx + delta + candidates.length) % candidates.length;
416
+ }
417
+ setHighlightedValue(candidates[next].value);
418
+ };
419
+ const handleKeyDown = (e) => {
420
+ if (e.key === "ArrowDown") {
421
+ e.preventDefault();
422
+ moveHighlight(1);
423
+ } else if (e.key === "ArrowUp") {
424
+ e.preventDefault();
425
+ moveHighlight(-1);
426
+ } else if (e.key === "Home") {
427
+ e.preventDefault();
428
+ const candidates = getCandidates();
429
+ if (candidates.length) setHighlightedValue(candidates[0].value);
430
+ } else if (e.key === "End") {
431
+ e.preventDefault();
432
+ const candidates = getCandidates();
433
+ if (candidates.length) setHighlightedValue(candidates[candidates.length - 1].value);
434
+ } else if (e.key === "Enter") {
435
+ if (highlightedValue !== void 0) {
436
+ e.preventDefault();
437
+ onValueChange(highlightedValue);
438
+ setOpen(false);
439
+ setTimeout(() => triggerRef.current?.focus(), 0);
440
+ }
441
+ } else if (e.key === "Escape") {
442
+ e.preventDefault();
443
+ setOpen(false);
444
+ setTimeout(() => triggerRef.current?.focus(), 0);
445
+ } else if (e.key === "Tab") {
446
+ setOpen(false);
447
+ }
448
+ onKeyDown?.(e);
449
+ };
450
+ return /* @__PURE__ */ jsx(
451
+ "input",
452
+ {
453
+ ...props,
454
+ ref,
455
+ id: ids.input,
456
+ type: "text",
457
+ role: "combobox",
458
+ autoComplete: "off",
459
+ spellCheck: false,
460
+ "aria-autocomplete": "list",
461
+ "aria-expanded": open,
462
+ "aria-controls": ids.list,
463
+ "aria-activedescendant": highlightedValue ? ids.item(highlightedValue) : void 0,
464
+ value: query,
465
+ placeholder,
466
+ onChange: handleChange,
467
+ onKeyDown: handleKeyDown,
468
+ className: cn(comboboxInputVariants(), className)
469
+ }
470
+ );
471
+ }
472
+ );
473
+ var ComboboxList = React.forwardRef(
474
+ function ComboboxList2({ className, children, ...props }, ref) {
475
+ const { ids } = useComboboxContext();
476
+ return /* @__PURE__ */ jsx(
477
+ "div",
478
+ {
479
+ ...props,
480
+ ref,
481
+ id: ids.list,
482
+ role: "listbox",
483
+ className: cn(comboboxListVariants(), className),
484
+ children
485
+ }
486
+ );
487
+ }
488
+ );
489
+ var ComboboxItem = React.forwardRef(
490
+ function ComboboxItem2({ className, children, value: itemValue, disabled: itemDisabled = false, label, ...props }, ref) {
491
+ const ctx = useComboboxContext();
492
+ const {
493
+ value,
494
+ onValueChange,
495
+ setOpen,
496
+ highlightedValue,
497
+ setHighlightedValue,
498
+ registerItem,
499
+ unregisterItem,
500
+ itemMatchesQuery,
501
+ ids,
502
+ triggerRef
503
+ } = ctx;
504
+ const isSelected = value === itemValue;
505
+ const itemId = ids.item(itemValue);
506
+ const labelText = label ?? (typeof children === "string" ? children : itemValue);
507
+ React.useEffect(() => {
508
+ registerItem({ id: itemId, value: itemValue, disabled: itemDisabled, label: labelText });
509
+ return () => unregisterItem(itemId);
510
+ }, [itemId, itemValue, itemDisabled, labelText, registerItem, unregisterItem]);
511
+ const matches = itemMatchesQuery(labelText, itemValue, itemDisabled);
512
+ const isHighlighted = highlightedValue === itemValue && matches && !itemDisabled;
513
+ const handleClick = () => {
514
+ if (itemDisabled) return;
515
+ onValueChange(itemValue);
516
+ setOpen(false);
517
+ setTimeout(() => triggerRef.current?.focus(), 0);
518
+ };
519
+ const handlePointerMove = () => {
520
+ if (itemDisabled) return;
521
+ if (highlightedValue !== itemValue) setHighlightedValue(itemValue);
522
+ };
523
+ if (!matches) {
524
+ return /* @__PURE__ */ jsx(
525
+ "div",
526
+ {
527
+ ref,
528
+ id: itemId,
529
+ "data-value": itemValue,
530
+ "data-hidden": "",
531
+ hidden: true,
532
+ "aria-hidden": "true"
533
+ }
534
+ );
535
+ }
536
+ return /* @__PURE__ */ jsx(
537
+ "div",
538
+ {
539
+ ...props,
540
+ ref,
541
+ id: itemId,
542
+ role: "option",
543
+ "aria-selected": isSelected,
544
+ "aria-disabled": itemDisabled || void 0,
545
+ "data-value": itemValue,
546
+ "data-state": isSelected ? "checked" : void 0,
547
+ "data-highlighted": isHighlighted ? "" : void 0,
548
+ "data-disabled": itemDisabled ? "" : void 0,
549
+ className: cn(
550
+ comboboxItemVariants({ selected: isSelected ? "true" : "false" }),
551
+ className
552
+ ),
553
+ onClick: handleClick,
554
+ onPointerMove: handlePointerMove,
555
+ children
556
+ }
557
+ );
558
+ }
559
+ );
560
+ var ComboboxEmpty = React.forwardRef(
561
+ function ComboboxEmpty2({ className, children, ...props }, ref) {
562
+ const ctx = useComboboxContext();
563
+ const { contentRef, query, options, hasOptions, filter } = ctx;
564
+ const [hasVisible, setHasVisible] = React.useState(true);
565
+ React.useEffect(() => {
566
+ if (hasOptions) {
567
+ const visible = options.some(
568
+ (o) => filter({ value: o.value, label: o.label, disabled: o.disabled }, query)
569
+ );
570
+ setHasVisible(visible);
571
+ return;
572
+ }
573
+ const root = contentRef.current;
574
+ if (!root) {
575
+ setHasVisible(true);
576
+ return;
577
+ }
578
+ const els = root.querySelectorAll('[role="option"]:not([data-hidden])');
579
+ setHasVisible(els.length > 0);
580
+ });
581
+ if (hasVisible) return null;
582
+ return /* @__PURE__ */ jsx(
583
+ "div",
584
+ {
585
+ ...props,
586
+ ref,
587
+ role: "presentation",
588
+ className: cn(comboboxEmptyVariants(), className),
589
+ children: children ?? "No results."
590
+ }
591
+ );
592
+ }
593
+ );
594
+ export {
595
+ Combobox,
596
+ ComboboxContent,
597
+ ComboboxEmpty,
598
+ ComboboxInput,
599
+ ComboboxItem,
600
+ ComboboxList,
601
+ ComboboxTrigger,
602
+ comboboxContentVariants,
603
+ comboboxEmptyVariants,
604
+ comboboxInputVariants,
605
+ comboboxItemVariants,
606
+ comboboxListVariants,
607
+ comboboxTriggerVariants
608
+ };
609
+ //# sourceMappingURL=react-combobox.js.map