@constructive-io/ui 0.6.0 → 0.8.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 (414) hide show
  1. package/dist/button-D4vqTxhp.d.cts +20 -0
  2. package/dist/button-D4vqTxhp.d.ts +20 -0
  3. package/dist/components/alert-dialog.cjs +98 -302
  4. package/dist/components/alert-dialog.cjs.map +1 -1
  5. package/dist/components/alert-dialog.d.cts +22 -21
  6. package/dist/components/alert-dialog.d.ts +22 -21
  7. package/dist/components/alert-dialog.js +96 -281
  8. package/dist/components/alert-dialog.js.map +1 -1
  9. package/dist/components/alert.cjs +51 -108
  10. package/dist/components/alert.cjs.map +1 -1
  11. package/dist/components/alert.d.cts +13 -13
  12. package/dist/components/alert.d.ts +13 -13
  13. package/dist/components/alert.js +49 -87
  14. package/dist/components/alert.js.map +1 -1
  15. package/dist/components/app-bar.cjs +73 -359
  16. package/dist/components/app-bar.cjs.map +1 -1
  17. package/dist/components/app-bar.d.cts +21 -20
  18. package/dist/components/app-bar.d.ts +21 -20
  19. package/dist/components/app-bar.js +71 -338
  20. package/dist/components/app-bar.js.map +1 -1
  21. package/dist/components/app-shell.cjs +252 -1777
  22. package/dist/components/app-shell.cjs.map +1 -1
  23. package/dist/components/app-shell.d.cts +77 -85
  24. package/dist/components/app-shell.d.ts +77 -85
  25. package/dist/components/app-shell.js +249 -1756
  26. package/dist/components/app-shell.js.map +1 -1
  27. package/dist/components/autocomplete.cjs +146 -397
  28. package/dist/components/autocomplete.cjs.map +1 -1
  29. package/dist/components/autocomplete.d.cts +24 -24
  30. package/dist/components/autocomplete.d.ts +24 -24
  31. package/dist/components/autocomplete.js +146 -376
  32. package/dist/components/autocomplete.js.map +1 -1
  33. package/dist/components/avatar.cjs +26 -38
  34. package/dist/components/avatar.cjs.map +1 -1
  35. package/dist/components/avatar.d.cts +11 -10
  36. package/dist/components/avatar.d.ts +11 -10
  37. package/dist/components/avatar.js +24 -37
  38. package/dist/components/avatar.js.map +1 -1
  39. package/dist/components/badge.cjs +42 -60
  40. package/dist/components/badge.cjs.map +1 -1
  41. package/dist/components/badge.d.cts +13 -13
  42. package/dist/components/badge.d.ts +13 -13
  43. package/dist/components/badge.js +39 -38
  44. package/dist/components/badge.js.map +1 -1
  45. package/dist/components/breadcrumb.cjs +65 -94
  46. package/dist/components/breadcrumb.cjs.map +1 -1
  47. package/dist/components/breadcrumb.d.cts +14 -13
  48. package/dist/components/breadcrumb.d.ts +14 -13
  49. package/dist/components/breadcrumb.js +63 -73
  50. package/dist/components/breadcrumb.js.map +1 -1
  51. package/dist/components/button.cjs +68 -162
  52. package/dist/components/button.cjs.map +1 -1
  53. package/dist/components/button.d.cts +2 -20
  54. package/dist/components/button.d.ts +2 -20
  55. package/dist/components/button.js +65 -140
  56. package/dist/components/button.js.map +1 -1
  57. package/dist/components/calendar-rac.cjs +49 -62
  58. package/dist/components/calendar-rac.cjs.map +1 -1
  59. package/dist/components/calendar-rac.d.cts +8 -8
  60. package/dist/components/calendar-rac.d.ts +8 -8
  61. package/dist/components/calendar-rac.js +49 -61
  62. package/dist/components/calendar-rac.js.map +1 -1
  63. package/dist/components/card.cjs +61 -74
  64. package/dist/components/card.cjs.map +1 -1
  65. package/dist/components/card.d.cts +15 -16
  66. package/dist/components/card.d.ts +15 -16
  67. package/dist/components/card.js +58 -72
  68. package/dist/components/card.js.map +1 -1
  69. package/dist/components/checkbox-group.cjs +12 -11
  70. package/dist/components/checkbox-group.cjs.map +1 -1
  71. package/dist/components/checkbox-group.d.cts +5 -5
  72. package/dist/components/checkbox-group.d.ts +5 -5
  73. package/dist/components/checkbox-group.js +12 -10
  74. package/dist/components/checkbox-group.js.map +1 -1
  75. package/dist/components/checkbox.cjs +60 -114
  76. package/dist/components/checkbox.cjs.map +1 -1
  77. package/dist/components/checkbox.d.cts +6 -6
  78. package/dist/components/checkbox.d.ts +6 -6
  79. package/dist/components/checkbox.js +58 -93
  80. package/dist/components/checkbox.js.map +1 -1
  81. package/dist/components/collapsible.cjs +76 -113
  82. package/dist/components/collapsible.cjs.map +1 -1
  83. package/dist/components/collapsible.d.cts +16 -15
  84. package/dist/components/collapsible.d.ts +16 -15
  85. package/dist/components/collapsible.js +74 -92
  86. package/dist/components/collapsible.js.map +1 -1
  87. package/dist/components/combobox.cjs +213 -507
  88. package/dist/components/combobox.cjs.map +1 -1
  89. package/dist/components/combobox.d.cts +36 -35
  90. package/dist/components/combobox.d.ts +36 -35
  91. package/dist/components/combobox.js +229 -504
  92. package/dist/components/combobox.js.map +1 -1
  93. package/dist/components/command.cjs +102 -199
  94. package/dist/components/command.cjs.map +1 -1
  95. package/dist/components/command.d.cts +22 -21
  96. package/dist/components/command.d.ts +22 -21
  97. package/dist/components/command.js +100 -198
  98. package/dist/components/command.js.map +1 -1
  99. package/dist/components/dialog.cjs +110 -402
  100. package/dist/components/dialog.cjs.map +1 -1
  101. package/dist/components/dialog.d.cts +27 -26
  102. package/dist/components/dialog.d.ts +27 -26
  103. package/dist/components/dialog.js +107 -380
  104. package/dist/components/dialog.js.map +1 -1
  105. package/dist/components/dock.cjs +80 -111
  106. package/dist/components/dock.cjs.map +1 -1
  107. package/dist/components/dock.d.cts +25 -25
  108. package/dist/components/dock.d.ts +25 -25
  109. package/dist/components/dock.js +78 -106
  110. package/dist/components/dock.js.map +1 -1
  111. package/dist/components/drawer.cjs +77 -111
  112. package/dist/components/drawer.cjs.map +1 -1
  113. package/dist/components/drawer.d.cts +15 -14
  114. package/dist/components/drawer.d.ts +15 -14
  115. package/dist/components/drawer.js +75 -90
  116. package/dist/components/drawer.js.map +1 -1
  117. package/dist/components/dropdown-menu.cjs +163 -238
  118. package/dist/components/dropdown-menu.cjs.map +1 -1
  119. package/dist/components/dropdown-menu.d.cts +44 -43
  120. package/dist/components/dropdown-menu.d.ts +44 -43
  121. package/dist/components/dropdown-menu.js +161 -217
  122. package/dist/components/dropdown-menu.js.map +1 -1
  123. package/dist/components/empty.cjs +51 -85
  124. package/dist/components/empty.cjs.map +1 -1
  125. package/dist/components/empty.d.cts +13 -13
  126. package/dist/components/empty.d.ts +13 -13
  127. package/dist/components/empty.js +48 -83
  128. package/dist/components/empty.js.map +1 -1
  129. package/dist/components/field.cjs +150 -259
  130. package/dist/components/field.cjs.map +1 -1
  131. package/dist/components/field.d.cts +39 -39
  132. package/dist/components/field.d.ts +39 -39
  133. package/dist/components/field.js +148 -238
  134. package/dist/components/field.js.map +1 -1
  135. package/dist/components/flickering-grid.cjs +143 -166
  136. package/dist/components/flickering-grid.cjs.map +1 -1
  137. package/dist/components/flickering-grid.d.cts +14 -13
  138. package/dist/components/flickering-grid.d.ts +14 -13
  139. package/dist/components/flickering-grid.js +141 -161
  140. package/dist/components/flickering-grid.js.map +1 -1
  141. package/dist/components/flow-zoom-panel.cjs +56 -188
  142. package/dist/components/flow-zoom-panel.cjs.map +1 -1
  143. package/dist/components/flow-zoom-panel.d.cts +9 -9
  144. package/dist/components/flow-zoom-panel.d.ts +9 -9
  145. package/dist/components/flow-zoom-panel.js +56 -168
  146. package/dist/components/flow-zoom-panel.js.map +1 -1
  147. package/dist/components/form-control.cjs +58 -186
  148. package/dist/components/form-control.cjs.map +1 -1
  149. package/dist/components/form-control.d.cts +11 -10
  150. package/dist/components/form-control.d.ts +11 -10
  151. package/dist/components/form-control.js +56 -165
  152. package/dist/components/form-control.js.map +1 -1
  153. package/dist/components/form.cjs +78 -184
  154. package/dist/components/form.cjs.map +1 -1
  155. package/dist/components/form.d.cts +2 -36
  156. package/dist/components/form.d.ts +2 -36
  157. package/dist/components/form.js +76 -163
  158. package/dist/components/form.js.map +1 -1
  159. package/dist/components/input-group.cjs +51 -165
  160. package/dist/components/input-group.cjs.map +1 -1
  161. package/dist/components/input-group.d.cts +14 -15
  162. package/dist/components/input-group.d.ts +14 -15
  163. package/dist/components/input-group.js +51 -164
  164. package/dist/components/input-group.js.map +1 -1
  165. package/dist/components/input.cjs +30 -55
  166. package/dist/components/input.cjs.map +1 -1
  167. package/dist/components/input.d.cts +2 -10
  168. package/dist/components/input.d.ts +2 -10
  169. package/dist/components/input.js +30 -54
  170. package/dist/components/input.js.map +1 -1
  171. package/dist/components/json-input.cjs +133 -337
  172. package/dist/components/json-input.cjs.map +1 -1
  173. package/dist/components/json-input.d.cts +20 -19
  174. package/dist/components/json-input.d.ts +20 -19
  175. package/dist/components/json-input.js +132 -317
  176. package/dist/components/json-input.js.map +1 -1
  177. package/dist/components/label.cjs +19 -21
  178. package/dist/components/label.cjs.map +1 -1
  179. package/dist/components/label.d.cts +6 -5
  180. package/dist/components/label.d.ts +6 -5
  181. package/dist/components/label.js +17 -20
  182. package/dist/components/label.js.map +1 -1
  183. package/dist/components/motion-grid.cjs +61 -101
  184. package/dist/components/motion-grid.cjs.map +1 -1
  185. package/dist/components/motion-grid.d.cts +15 -14
  186. package/dist/components/motion-grid.d.ts +15 -14
  187. package/dist/components/motion-grid.js +59 -80
  188. package/dist/components/motion-grid.js.map +1 -1
  189. package/dist/components/multi-select.cjs +563 -786
  190. package/dist/components/multi-select.cjs.map +1 -1
  191. package/dist/components/multi-select.d.cts +173 -173
  192. package/dist/components/multi-select.d.ts +173 -173
  193. package/dist/components/multi-select.js +561 -765
  194. package/dist/components/multi-select.js.map +1 -1
  195. package/dist/components/page-header.cjs +24 -13
  196. package/dist/components/page-header.cjs.map +1 -1
  197. package/dist/components/page-header.d.cts +11 -11
  198. package/dist/components/page-header.d.ts +11 -11
  199. package/dist/components/page-header.js +23 -11
  200. package/dist/components/page-header.js.map +1 -1
  201. package/dist/components/pagination.cjs +72 -272
  202. package/dist/components/pagination.cjs.map +1 -1
  203. package/dist/components/pagination.d.cts +15 -16
  204. package/dist/components/pagination.d.ts +15 -16
  205. package/dist/components/pagination.js +69 -250
  206. package/dist/components/pagination.js.map +1 -1
  207. package/dist/components/popover.cjs +68 -111
  208. package/dist/components/popover.cjs.map +1 -1
  209. package/dist/components/popover.d.cts +31 -30
  210. package/dist/components/popover.d.ts +31 -30
  211. package/dist/components/popover.js +66 -90
  212. package/dist/components/popover.js.map +1 -1
  213. package/dist/components/portal.cjs +128 -81
  214. package/dist/components/portal.cjs.map +1 -1
  215. package/dist/components/portal.d.cts +24 -23
  216. package/dist/components/portal.d.ts +24 -23
  217. package/dist/components/portal.js +126 -60
  218. package/dist/components/portal.js.map +1 -1
  219. package/dist/components/progress.cjs +23 -24
  220. package/dist/components/progress.cjs.map +1 -1
  221. package/dist/components/progress.d.cts +8 -7
  222. package/dist/components/progress.d.ts +8 -7
  223. package/dist/components/progress.js +21 -23
  224. package/dist/components/progress.js.map +1 -1
  225. package/dist/components/progressive-blur-scroll-container.cjs +70 -138
  226. package/dist/components/progressive-blur-scroll-container.cjs.map +1 -1
  227. package/dist/components/progressive-blur-scroll-container.d.cts +19 -19
  228. package/dist/components/progressive-blur-scroll-container.d.ts +19 -19
  229. package/dist/components/progressive-blur-scroll-container.js +70 -137
  230. package/dist/components/progressive-blur-scroll-container.js.map +1 -1
  231. package/dist/components/progressive-blur.cjs +40 -64
  232. package/dist/components/progressive-blur.cjs.map +1 -1
  233. package/dist/components/progressive-blur.d.cts +15 -14
  234. package/dist/components/progressive-blur.d.ts +15 -14
  235. package/dist/components/progressive-blur.js +38 -63
  236. package/dist/components/progressive-blur.js.map +1 -1
  237. package/dist/components/radio-group.cjs +28 -42
  238. package/dist/components/radio-group.cjs.map +1 -1
  239. package/dist/components/radio-group.d.cts +8 -8
  240. package/dist/components/radio-group.d.ts +8 -8
  241. package/dist/components/radio-group.js +28 -41
  242. package/dist/components/radio-group.js.map +1 -1
  243. package/dist/components/record-picker.cjs +6 -418
  244. package/dist/components/record-picker.d.cts +13 -13
  245. package/dist/components/record-picker.d.ts +13 -13
  246. package/dist/components/record-picker.js +5 -397
  247. package/dist/components/resizable.cjs +32 -58
  248. package/dist/components/resizable.cjs.map +1 -1
  249. package/dist/components/resizable.d.cts +10 -9
  250. package/dist/components/resizable.d.ts +10 -9
  251. package/dist/components/resizable.js +29 -37
  252. package/dist/components/resizable.js.map +1 -1
  253. package/dist/components/responsive-diagram.cjs +50 -61
  254. package/dist/components/responsive-diagram.cjs.map +1 -1
  255. package/dist/components/responsive-diagram.d.cts +7 -7
  256. package/dist/components/responsive-diagram.d.ts +7 -7
  257. package/dist/components/responsive-diagram.js +50 -60
  258. package/dist/components/responsive-diagram.js.map +1 -1
  259. package/dist/components/scroll-area.cjs +37 -83
  260. package/dist/components/scroll-area.cjs.map +1 -1
  261. package/dist/components/scroll-area.d.cts +9 -8
  262. package/dist/components/scroll-area.d.ts +9 -8
  263. package/dist/components/scroll-area.js +35 -62
  264. package/dist/components/scroll-area.js.map +1 -1
  265. package/dist/components/select.cjs +175 -300
  266. package/dist/components/select.cjs.map +1 -1
  267. package/dist/components/select.d.cts +36 -35
  268. package/dist/components/select.d.ts +36 -35
  269. package/dist/components/select.js +172 -278
  270. package/dist/components/select.js.map +1 -1
  271. package/dist/components/separator.cjs +16 -19
  272. package/dist/components/separator.cjs.map +1 -1
  273. package/dist/components/separator.d.cts +2 -10
  274. package/dist/components/separator.d.ts +2 -10
  275. package/dist/components/separator.js +14 -18
  276. package/dist/components/separator.js.map +1 -1
  277. package/dist/components/sheet.cjs +17 -487
  278. package/dist/components/sheet.d.cts +85 -85
  279. package/dist/components/sheet.d.ts +85 -85
  280. package/dist/components/sheet.js +3 -453
  281. package/dist/components/sidebar.cjs +27 -1298
  282. package/dist/components/sidebar.d.cts +62 -65
  283. package/dist/components/sidebar.d.ts +62 -65
  284. package/dist/components/sidebar.js +3 -1254
  285. package/dist/components/skeleton.cjs +18 -30
  286. package/dist/components/skeleton.cjs.map +1 -1
  287. package/dist/components/skeleton.d.cts +6 -5
  288. package/dist/components/skeleton.d.ts +6 -5
  289. package/dist/components/skeleton.js +15 -28
  290. package/dist/components/skeleton.js.map +1 -1
  291. package/dist/components/sonner.cjs +17 -19
  292. package/dist/components/sonner.cjs.map +1 -1
  293. package/dist/components/sonner.d.cts +7 -7
  294. package/dist/components/sonner.d.ts +7 -7
  295. package/dist/components/sonner.js +17 -18
  296. package/dist/components/sonner.js.map +1 -1
  297. package/dist/components/stack/index.cjs +43 -1515
  298. package/dist/components/stack/index.d.cts +2 -672
  299. package/dist/components/stack/index.d.ts +2 -672
  300. package/dist/components/stack/index.js +3 -1455
  301. package/dist/components/stepper.cjs +131 -285
  302. package/dist/components/stepper.cjs.map +1 -1
  303. package/dist/components/stepper.d.cts +27 -26
  304. package/dist/components/stepper.d.ts +27 -26
  305. package/dist/components/stepper.js +130 -265
  306. package/dist/components/stepper.js.map +1 -1
  307. package/dist/components/switch.cjs +21 -32
  308. package/dist/components/switch.cjs.map +1 -1
  309. package/dist/components/switch.d.cts +7 -6
  310. package/dist/components/switch.d.ts +7 -6
  311. package/dist/components/switch.js +19 -31
  312. package/dist/components/switch.js.map +1 -1
  313. package/dist/components/table.cjs +58 -106
  314. package/dist/components/table.cjs.map +1 -1
  315. package/dist/components/table.d.cts +17 -16
  316. package/dist/components/table.d.ts +17 -16
  317. package/dist/components/table.js +55 -104
  318. package/dist/components/table.js.map +1 -1
  319. package/dist/components/tabs.cjs +31 -35
  320. package/dist/components/tabs.cjs.map +1 -1
  321. package/dist/components/tabs.d.cts +9 -8
  322. package/dist/components/tabs.d.ts +9 -8
  323. package/dist/components/tabs.js +29 -34
  324. package/dist/components/tabs.js.map +1 -1
  325. package/dist/components/tags.cjs +114 -433
  326. package/dist/components/tags.cjs.map +1 -1
  327. package/dist/components/tags.d.cts +24 -28
  328. package/dist/components/tags.d.ts +24 -28
  329. package/dist/components/tags.js +114 -413
  330. package/dist/components/tags.js.map +1 -1
  331. package/dist/components/textarea.cjs +27 -49
  332. package/dist/components/textarea.cjs.map +1 -1
  333. package/dist/components/textarea.d.cts +8 -7
  334. package/dist/components/textarea.d.ts +8 -7
  335. package/dist/components/textarea.js +27 -48
  336. package/dist/components/textarea.js.map +1 -1
  337. package/dist/components/toast/index.cjs +9 -612
  338. package/dist/components/toast/index.d.cts +2 -52
  339. package/dist/components/toast/index.d.ts +2 -52
  340. package/dist/components/toast/index.js +3 -586
  341. package/dist/components/tooltip.cjs +47 -72
  342. package/dist/components/tooltip.cjs.map +1 -1
  343. package/dist/components/tooltip.d.cts +2 -28
  344. package/dist/components/tooltip.d.ts +2 -28
  345. package/dist/components/tooltip.js +45 -51
  346. package/dist/components/tooltip.js.map +1 -1
  347. package/dist/components/unlink-button.cjs +19 -192
  348. package/dist/components/unlink-button.cjs.map +1 -1
  349. package/dist/components/unlink-button.d.cts +11 -11
  350. package/dist/components/unlink-button.d.ts +11 -11
  351. package/dist/components/unlink-button.js +18 -170
  352. package/dist/components/unlink-button.js.map +1 -1
  353. package/dist/form-DgRTv7O7.d.ts +54 -0
  354. package/dist/form-DoZEWSzb.d.cts +54 -0
  355. package/dist/index-CjA4CENl.d.cts +684 -0
  356. package/dist/index-CjA4CENl.d.ts +684 -0
  357. package/dist/index-UnM04j0t.d.cts +58 -0
  358. package/dist/index-UnM04j0t.d.ts +58 -0
  359. package/dist/index.cjs +408 -8697
  360. package/dist/index.d.cts +224 -2136
  361. package/dist/index.d.ts +224 -2136
  362. package/dist/index.js +65 -8350
  363. package/dist/input-CBrCuMH8.d.cts +11 -0
  364. package/dist/input-CBrCuMH8.d.ts +11 -0
  365. package/dist/motion-config-COCFHq1L.cjs +271 -0
  366. package/dist/motion-config-COCFHq1L.cjs.map +1 -0
  367. package/dist/motion-config-COsZ6azM.js +241 -0
  368. package/dist/motion-config-COsZ6azM.js.map +1 -0
  369. package/dist/record-picker-BbxngCeV.js +162 -0
  370. package/dist/record-picker-BbxngCeV.js.map +1 -0
  371. package/dist/record-picker-Bz4FApxD.cjs +167 -0
  372. package/dist/record-picker-Bz4FApxD.cjs.map +1 -0
  373. package/dist/rolldown-runtime-D_qnwXdH.cjs +35 -0
  374. package/dist/separator-BQEsr0Rc.d.cts +11 -0
  375. package/dist/separator-BQEsr0Rc.d.ts +11 -0
  376. package/dist/sheet-BLHnhLRH.js +425 -0
  377. package/dist/sheet-BLHnhLRH.js.map +1 -0
  378. package/dist/sheet-BdA0rfIz.cjs +515 -0
  379. package/dist/sheet-BdA0rfIz.cjs.map +1 -0
  380. package/dist/sidebar-BavjjJp0.cjs +625 -0
  381. package/dist/sidebar-BavjjJp0.cjs.map +1 -0
  382. package/dist/sidebar-DeoL2ttp.js +481 -0
  383. package/dist/sidebar-DeoL2ttp.js.map +1 -0
  384. package/dist/slot-C-jEfihz.cjs +122 -0
  385. package/dist/slot-C-jEfihz.cjs.map +1 -0
  386. package/dist/slot-EL8zfLG0.js +97 -0
  387. package/dist/slot-EL8zfLG0.js.map +1 -0
  388. package/dist/stack-DKdvlOM6.cjs +1771 -0
  389. package/dist/stack-DKdvlOM6.cjs.map +1 -0
  390. package/dist/stack-jMdxDrex.js +1531 -0
  391. package/dist/stack-jMdxDrex.js.map +1 -0
  392. package/dist/toast-D6MqijT2.cjs +316 -0
  393. package/dist/toast-D6MqijT2.cjs.map +1 -0
  394. package/dist/toast-D_BOLzm3.js +287 -0
  395. package/dist/toast-D_BOLzm3.js.map +1 -0
  396. package/dist/tooltip-CTRQoN1A.d.cts +29 -0
  397. package/dist/tooltip-CTRQoN1A.d.ts +29 -0
  398. package/dist/utils-BkMLyah9.js +12 -0
  399. package/dist/utils-BkMLyah9.js.map +1 -0
  400. package/dist/utils-CzTQ3-VI.cjs +17 -0
  401. package/dist/utils-CzTQ3-VI.cjs.map +1 -0
  402. package/package.json +5 -5
  403. package/dist/components/record-picker.cjs.map +0 -1
  404. package/dist/components/record-picker.js.map +0 -1
  405. package/dist/components/sheet.cjs.map +0 -1
  406. package/dist/components/sheet.js.map +0 -1
  407. package/dist/components/sidebar.cjs.map +0 -1
  408. package/dist/components/sidebar.js.map +0 -1
  409. package/dist/components/stack/index.cjs.map +0 -1
  410. package/dist/components/stack/index.js.map +0 -1
  411. package/dist/components/toast/index.cjs.map +0 -1
  412. package/dist/components/toast/index.js.map +0 -1
  413. package/dist/index.cjs.map +0 -1
  414. package/dist/index.js.map +0 -1
@@ -1,774 +1,570 @@
1
- "use client";
2
- import * as React3 from 'react';
3
- import { cva } from 'class-variance-authority';
4
- import { XCircle, XIcon, ChevronDown, SearchIcon, CheckIcon } from 'lucide-react';
5
- import { clsx } from 'clsx';
6
- import { twMerge } from 'tailwind-merge';
7
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
8
- import { Popover as Popover$1 } from '@base-ui/react/popover';
9
- import { useFloatingOverlayPortalProps } from '@constructive-io/ui/portal';
10
- import { Separator as Separator$1 } from '@base-ui/react/separator';
1
+ 'use client';
11
2
 
12
- function cn(...inputs) {
13
- return twMerge(clsx(inputs));
14
- }
15
- var badgeVariants = cva(
16
- "relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button,a&]:cursor-pointer [button,a&]:pointer-coarse:min-h-11 [button,a&]:pointer-coarse:min-w-11",
17
- {
18
- defaultVariants: {
19
- size: "default",
20
- variant: "default"
21
- },
22
- variants: {
23
- size: {
24
- default: "px-[calc(--spacing(1)-1px)] text-xs",
25
- lg: "px-[calc(--spacing(1.5)-1px)] text-sm",
26
- sm: "rounded-[calc(var(--radius-sm)-2px)] px-[calc(--spacing(1)-1px)] text-[.625rem]"
27
- },
28
- variant: {
29
- default: "bg-primary text-primary-foreground [button,a&]:hover:bg-primary/90",
30
- destructive: "bg-destructive text-white [button,a&]:hover:bg-destructive/90",
31
- error: "bg-destructive/8 text-destructive dark:bg-destructive/16",
32
- info: "bg-info/8 text-info-foreground dark:bg-info/16",
33
- outline: "border-border/60 bg-transparent dark:bg-input/32 [button,a&]:hover:bg-accent/50 dark:[button,a&]:hover:bg-input/48",
34
- secondary: "bg-secondary text-secondary-foreground [button,a&]:hover:bg-secondary/90",
35
- success: "bg-success/8 text-success-foreground dark:bg-success/16",
36
- warning: "bg-warning/8 text-warning-foreground dark:bg-warning/16"
37
- }
38
- }
39
- }
40
- );
41
- var Badge = React3.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsx("span", { ref, "data-slot": "badge", className: cn(badgeVariants({ variant, size }), className), ...props }));
42
- Badge.displayName = "Badge";
43
- function Popover({ ...props }) {
44
- return /* @__PURE__ */ jsx(Popover$1.Root, { "data-slot": "popover", ...props });
45
- }
46
- function PopoverTrigger({ asChild, children, render, nativeButton, ...props }) {
47
- const childRender = render === void 0 && asChild && React3.isValidElement(children) ? children : void 0;
48
- return /* @__PURE__ */ jsx(
49
- Popover$1.Trigger,
50
- {
51
- "data-slot": "popover-trigger",
52
- nativeButton: nativeButton ?? (childRender ? true : void 0),
53
- render: render ?? childRender,
54
- ...props,
55
- children: childRender ? void 0 : children
56
- }
57
- );
58
- }
59
- function PopoverContent({
60
- className,
61
- align = "center",
62
- sideOffset = 4,
63
- showArrow = false,
64
- side = "bottom",
65
- children,
66
- onOpenAutoFocus: _onOpenAutoFocus,
67
- onCloseAutoFocus: _onCloseAutoFocus,
68
- onFocusOutside: _onFocusOutside,
69
- onEscapeKeyDown: _onEscapeKeyDown,
70
- ...props
71
- }) {
72
- const { container, zIndexClass } = useFloatingOverlayPortalProps();
73
- return /* @__PURE__ */ jsx(Popover$1.Portal, { container, children: /* @__PURE__ */ jsx(
74
- Popover$1.Positioner,
75
- {
76
- side,
77
- align,
78
- sideOffset,
79
- className: zIndexClass,
80
- children: /* @__PURE__ */ jsxs(
81
- Popover$1.Popup,
82
- {
83
- "data-slot": "popover-content",
84
- className: cn(
85
- `bg-popover text-popover-foreground origin-(--transform-origin) w-72 rounded-md border p-4 shadow-md outline-hidden
86
- transition-[scale,opacity,translate] duration-150 ease-out data-starting-style:scale-95
87
- data-ending-style:scale-95 data-starting-style:opacity-0 data-ending-style:opacity-0
88
- data-[side=bottom]:data-starting-style:-translate-y-2
89
- data-[side=left]:data-starting-style:translate-x-2
90
- data-[side=right]:data-starting-style:-translate-x-2
91
- data-[side=top]:data-starting-style:translate-y-2 motion-reduce:transition-none`,
92
- className
93
- ),
94
- ...props,
95
- children: [
96
- children,
97
- showArrow && /* @__PURE__ */ jsx(Popover$1.Arrow, { className: "fill-popover -my-px drop-shadow-[0_1px_0_var(--border)]" })
98
- ]
99
- }
100
- )
101
- }
102
- ) });
103
- }
104
- function Separator({ className, orientation = "horizontal", decorative: _decorative, ...props }) {
105
- return /* @__PURE__ */ jsx(
106
- Separator$1,
107
- {
108
- "data-slot": "separator-root",
109
- orientation,
110
- className: cn("bg-border shrink-0", orientation === "horizontal" ? "h-px w-full" : "h-full w-px", className),
111
- ...props
112
- }
113
- );
114
- }
115
- var multiSelectVariants = cva("m-0.5 inline-flex items-center gap-0.5 rounded-full border px-2 py-1 text-xs", {
116
- variants: {
117
- variant: {
118
- default: "border-foreground/10 text-foreground bg-card",
119
- secondary: "border-foreground/10 bg-secondary text-secondary-foreground",
120
- destructive: "border-transparent bg-destructive text-destructive-foreground",
121
- inverted: "inverted"
122
- }
123
- },
124
- defaultVariants: {
125
- variant: "default"
126
- }
3
+ import { t as cn } from "../utils-BkMLyah9.js";
4
+ import { Badge } from "./badge.js";
5
+ import { Separator } from "./separator.js";
6
+ import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
7
+ import * as React$1 from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { cva } from "class-variance-authority";
10
+ import { CheckIcon, ChevronDown, SearchIcon, XCircle, XIcon } from "lucide-react";
11
+
12
+ //#region src/components/multi-select.tsx
13
+ /**
14
+ * Variants for the multi-select component to handle different styles.
15
+ * Uses class-variance-authority (cva) to define different styles based on "variant" prop.
16
+ */
17
+ const multiSelectVariants = cva("m-0.5 inline-flex items-center gap-0.5 rounded-full border px-2 py-1 text-xs", {
18
+ variants: { variant: {
19
+ default: "border-foreground/10 text-foreground bg-card",
20
+ secondary: "border-foreground/10 bg-secondary text-secondary-foreground",
21
+ destructive: "border-transparent bg-destructive text-destructive-foreground",
22
+ inverted: "inverted"
23
+ } },
24
+ defaultVariants: { variant: "default" }
127
25
  });
128
- function OptionItem({
129
- option,
130
- isSelected,
131
- onSelect,
132
- highlightedIndex,
133
- index,
134
- setHighlightedIndex
135
- }) {
136
- const isHighlighted = highlightedIndex === index;
137
- return /* @__PURE__ */ jsxs(
138
- "div",
139
- {
140
- role: "option",
141
- "aria-selected": isSelected,
142
- "aria-disabled": option.disabled,
143
- "data-highlighted": isHighlighted,
144
- "data-selected": isSelected,
145
- "data-disabled": option.disabled,
146
- tabIndex: -1,
147
- className: cn(
148
- "relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",
149
- "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground",
150
- "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50"
151
- ),
152
- onClick: (e) => {
153
- e.preventDefault();
154
- e.stopPropagation();
155
- if (!option.disabled) {
156
- onSelect();
157
- }
158
- },
159
- onMouseEnter: () => setHighlightedIndex(index),
160
- children: [
161
- /* @__PURE__ */ jsx(
162
- "div",
163
- {
164
- className: cn(
165
- "border-primary mr-2 flex h-4 w-4 items-center justify-center rounded-sm border",
166
- isSelected ? "bg-primary text-primary-foreground" : "opacity-60 [&_svg]:invisible"
167
- ),
168
- "aria-hidden": "true",
169
- children: /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4" })
170
- }
171
- ),
172
- option.icon && /* @__PURE__ */ jsx(option.icon, { className: "text-muted-foreground mr-2 h-4 w-4", "aria-hidden": "true" }),
173
- /* @__PURE__ */ jsx("span", { children: option.label }),
174
- option.description && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground ml-2 text-xs", children: option.description })
175
- ]
176
- }
177
- );
26
+ /**
27
+ * Individual option item component
28
+ */
29
+ function OptionItem({ option, isSelected, onSelect, highlightedIndex, index, setHighlightedIndex }) {
30
+ const isHighlighted = highlightedIndex === index;
31
+ return /* @__PURE__ */ jsxs("div", {
32
+ role: "option",
33
+ "aria-selected": isSelected,
34
+ "aria-disabled": option.disabled,
35
+ "data-highlighted": isHighlighted,
36
+ "data-selected": isSelected,
37
+ "data-disabled": option.disabled,
38
+ tabIndex: -1,
39
+ className: cn("relative flex cursor-pointer select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none", "data-[highlighted=true]:bg-accent data-[highlighted=true]:text-accent-foreground", "data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50"),
40
+ onClick: (e) => {
41
+ e.preventDefault();
42
+ e.stopPropagation();
43
+ if (!option.disabled) onSelect();
44
+ },
45
+ onMouseEnter: () => setHighlightedIndex(index),
46
+ children: [
47
+ /* @__PURE__ */ jsx("div", {
48
+ className: cn("border-primary mr-2 flex h-4 w-4 items-center justify-center rounded-sm border", isSelected ? "bg-primary text-primary-foreground" : "opacity-60 [&_svg]:invisible"),
49
+ "aria-hidden": "true",
50
+ children: /* @__PURE__ */ jsx(CheckIcon, { className: "h-4 w-4" })
51
+ }),
52
+ option.icon && /* @__PURE__ */ jsx(option.icon, {
53
+ className: "text-muted-foreground mr-2 h-4 w-4",
54
+ "aria-hidden": "true"
55
+ }),
56
+ /* @__PURE__ */ jsx("span", { children: option.label }),
57
+ option.description && /* @__PURE__ */ jsx("span", {
58
+ className: "text-muted-foreground ml-2 text-xs",
59
+ children: option.description
60
+ })
61
+ ]
62
+ });
178
63
  }
179
- var MultiSelect = React3.forwardRef(
180
- ({
181
- options,
182
- onValueChange,
183
- variant,
184
- defaultValue = [],
185
- placeholder = "Select options",
186
- maxCount = 3,
187
- className,
188
- searchable = true,
189
- emptyIndicator,
190
- autoSize = false,
191
- singleLine = false,
192
- popoverClassName,
193
- disabled = false,
194
- responsive,
195
- minWidth,
196
- maxWidth,
197
- dropdownMaxHeight,
198
- deduplicateOptions = false,
199
- footerContent,
200
- resetOnDefaultValueChange = true,
201
- closeOnSelect = false,
202
- onClick,
203
- ...props
204
- }, ref) => {
205
- const [selectedValues, setSelectedValues] = React3.useState(defaultValue);
206
- const [isPopoverOpen, setIsPopoverOpen] = React3.useState(false);
207
- const [searchValue, setSearchValue] = React3.useState("");
208
- const [highlightedIndex, setHighlightedIndex] = React3.useState(-1);
209
- const multiSelectId = React3.useId();
210
- const listboxId = `${multiSelectId}-listbox`;
211
- const triggerDescriptionId = `${multiSelectId}-description`;
212
- const selectedCountId = `${multiSelectId}-count`;
213
- const searchInputId = `${multiSelectId}-search`;
214
- const searchInputRef = React3.useRef(null);
215
- const listRef = React3.useRef(null);
216
- const prevDefaultValueRef = React3.useRef(defaultValue);
217
- const isGroupedOptions = React3.useCallback(
218
- (opts) => {
219
- return opts.length > 0 && "heading" in opts[0];
220
- },
221
- []
222
- );
223
- const arraysEqual = React3.useCallback((a, b) => {
224
- if (a.length !== b.length) return false;
225
- const sortedA = [...a].sort();
226
- const sortedB = [...b].sort();
227
- return sortedA.every((val, index) => val === sortedB[index]);
228
- }, []);
229
- const resetToDefault = React3.useCallback(() => {
230
- setSelectedValues(defaultValue);
231
- setIsPopoverOpen(false);
232
- setSearchValue("");
233
- onValueChange(defaultValue);
234
- }, [defaultValue, onValueChange]);
235
- const buttonRef = React3.useRef(null);
236
- React3.useImperativeHandle(
237
- ref,
238
- () => ({
239
- reset: resetToDefault,
240
- getSelectedValues: () => selectedValues,
241
- setSelectedValues: (values) => {
242
- setSelectedValues(values);
243
- onValueChange(values);
244
- },
245
- clear: () => {
246
- setSelectedValues([]);
247
- onValueChange([]);
248
- },
249
- focus: () => {
250
- if (buttonRef.current) {
251
- buttonRef.current.focus();
252
- const originalOutline = buttonRef.current.style.outline;
253
- const originalOutlineOffset = buttonRef.current.style.outlineOffset;
254
- buttonRef.current.style.outline = "2px solid hsl(var(--ring))";
255
- buttonRef.current.style.outlineOffset = "2px";
256
- setTimeout(() => {
257
- if (buttonRef.current) {
258
- buttonRef.current.style.outline = originalOutline;
259
- buttonRef.current.style.outlineOffset = originalOutlineOffset;
260
- }
261
- }, 1e3);
262
- }
263
- }
264
- }),
265
- [resetToDefault, selectedValues, onValueChange]
266
- );
267
- const [screenSize, setScreenSize] = React3.useState("desktop");
268
- React3.useEffect(() => {
269
- if (typeof window === "undefined") return;
270
- const handleResize = () => {
271
- const width = window.innerWidth;
272
- if (width < 640) {
273
- setScreenSize("mobile");
274
- } else if (width < 1024) {
275
- setScreenSize("tablet");
276
- } else {
277
- setScreenSize("desktop");
278
- }
279
- };
280
- handleResize();
281
- window.addEventListener("resize", handleResize);
282
- return () => {
283
- if (typeof window !== "undefined") {
284
- window.removeEventListener("resize", handleResize);
285
- }
286
- };
287
- }, []);
288
- const getResponsiveSettings = () => {
289
- if (!responsive) {
290
- return {
291
- maxCount,
292
- hideIcons: false,
293
- compactMode: false
294
- };
295
- }
296
- if (responsive === true) {
297
- const defaultResponsive = {
298
- mobile: { maxCount: 2, hideIcons: false, compactMode: true },
299
- tablet: { maxCount: 4, hideIcons: false, compactMode: false },
300
- desktop: { maxCount: 6, hideIcons: false, compactMode: false }
301
- };
302
- const currentSettings2 = defaultResponsive[screenSize];
303
- return {
304
- maxCount: currentSettings2?.maxCount ?? maxCount,
305
- hideIcons: currentSettings2?.hideIcons ?? false,
306
- compactMode: currentSettings2?.compactMode ?? false
307
- };
308
- }
309
- const currentSettings = responsive[screenSize];
310
- return {
311
- maxCount: currentSettings?.maxCount ?? maxCount,
312
- hideIcons: currentSettings?.hideIcons ?? false,
313
- compactMode: currentSettings?.compactMode ?? false
314
- };
315
- };
316
- const responsiveSettings = getResponsiveSettings();
317
- const getAllOptions = React3.useCallback(() => {
318
- if (options.length === 0) return [];
319
- let allOptions;
320
- if (isGroupedOptions(options)) {
321
- allOptions = options.flatMap((group) => group.options);
322
- } else {
323
- allOptions = options;
324
- }
325
- const valueSet = /* @__PURE__ */ new Set();
326
- const duplicates = [];
327
- const uniqueOptions = [];
328
- allOptions.forEach((option) => {
329
- if (valueSet.has(option.value)) {
330
- duplicates.push(option.value);
331
- if (!deduplicateOptions) {
332
- uniqueOptions.push(option);
333
- }
334
- } else {
335
- valueSet.add(option.value);
336
- uniqueOptions.push(option);
337
- }
338
- });
339
- if (process.env.NODE_ENV === "development" && duplicates.length > 0) {
340
- const action = deduplicateOptions ? "automatically removed" : "detected";
341
- console.warn(
342
- `MultiSelect: Duplicate option values ${action}: ${duplicates.join(", ")}. ${deduplicateOptions ? "Duplicates have been removed automatically." : "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."}`
343
- );
344
- }
345
- return deduplicateOptions ? uniqueOptions : allOptions;
346
- }, [options, deduplicateOptions, isGroupedOptions]);
347
- const getOptionByValue = React3.useCallback(
348
- (value) => {
349
- const option = getAllOptions().find((option2) => option2.value === value);
350
- if (!option && process.env.NODE_ENV === "development") {
351
- console.warn(`MultiSelect: Option with value "${value}" not found in options list`);
352
- }
353
- return option;
354
- },
355
- [getAllOptions]
356
- );
357
- const filteredOptions = React3.useMemo(() => {
358
- if (!searchable || !searchValue) return options;
359
- if (options.length === 0) return [];
360
- if (isGroupedOptions(options)) {
361
- return options.map((group) => ({
362
- ...group,
363
- options: group.options.filter(
364
- (option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase())
365
- )
366
- })).filter((group) => group.options.length > 0);
367
- }
368
- return options.filter(
369
- (option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase())
370
- );
371
- }, [options, searchValue, searchable, isGroupedOptions]);
372
- const flatFilteredOptions = React3.useMemo(() => {
373
- if (isGroupedOptions(filteredOptions)) {
374
- return filteredOptions.flatMap((group) => group.options);
375
- }
376
- return filteredOptions;
377
- }, [filteredOptions, isGroupedOptions]);
378
- const toggleOption = React3.useCallback(
379
- (optionValue) => {
380
- if (disabled) return;
381
- const option = getOptionByValue(optionValue);
382
- if (option?.disabled) return;
383
- const newSelectedValues = selectedValues.includes(optionValue) ? selectedValues.filter((value) => value !== optionValue) : [...selectedValues, optionValue];
384
- setSelectedValues(newSelectedValues);
385
- onValueChange(newSelectedValues);
386
- if (closeOnSelect) {
387
- setIsPopoverOpen(false);
388
- }
389
- },
390
- [disabled, getOptionByValue, selectedValues, onValueChange, closeOnSelect]
391
- );
392
- const handleClear = () => {
393
- if (disabled) return;
394
- setSelectedValues([]);
395
- onValueChange([]);
396
- };
397
- const handleTogglePopover = () => {
398
- if (disabled) return;
399
- setIsPopoverOpen((prev) => !prev);
400
- };
401
- const clearExtraOptions = () => {
402
- if (disabled) return;
403
- const newSelectedValues = selectedValues.slice(0, responsiveSettings.maxCount);
404
- setSelectedValues(newSelectedValues);
405
- onValueChange(newSelectedValues);
406
- };
407
- const handleKeyDown = React3.useCallback(
408
- (event) => {
409
- const optionsCount = flatFilteredOptions.length;
410
- if (optionsCount === 0) return;
411
- switch (event.key) {
412
- case "ArrowDown":
413
- event.preventDefault();
414
- setHighlightedIndex((prev) => prev < optionsCount - 1 ? prev + 1 : 0);
415
- break;
416
- case "ArrowUp":
417
- event.preventDefault();
418
- setHighlightedIndex((prev) => prev > 0 ? prev - 1 : optionsCount - 1);
419
- break;
420
- case "Enter":
421
- event.preventDefault();
422
- if (highlightedIndex >= 0 && highlightedIndex < optionsCount) {
423
- const option = flatFilteredOptions[highlightedIndex];
424
- if (option && !option.disabled) {
425
- toggleOption(option.value);
426
- }
427
- }
428
- break;
429
- case "Escape":
430
- event.preventDefault();
431
- setIsPopoverOpen(false);
432
- break;
433
- case "Backspace":
434
- if (!searchValue && selectedValues.length > 0) {
435
- const newSelectedValues = [...selectedValues];
436
- newSelectedValues.pop();
437
- setSelectedValues(newSelectedValues);
438
- onValueChange(newSelectedValues);
439
- }
440
- break;
441
- }
442
- },
443
- [flatFilteredOptions, highlightedIndex, toggleOption, searchValue, selectedValues, onValueChange]
444
- );
445
- React3.useEffect(() => {
446
- if (!resetOnDefaultValueChange) return;
447
- const prevDefaultValue = prevDefaultValueRef.current;
448
- if (!arraysEqual(prevDefaultValue, defaultValue)) {
449
- if (!arraysEqual(selectedValues, defaultValue)) {
450
- setSelectedValues(defaultValue);
451
- }
452
- prevDefaultValueRef.current = [...defaultValue];
453
- }
454
- }, [defaultValue, selectedValues, arraysEqual, resetOnDefaultValueChange]);
455
- const getWidthConstraints = () => {
456
- const defaultMinWidth = screenSize === "mobile" ? "0px" : "200px";
457
- const effectiveMinWidth = minWidth || defaultMinWidth;
458
- const effectiveMaxWidth = maxWidth || "100%";
459
- return {
460
- minWidth: effectiveMinWidth,
461
- maxWidth: effectiveMaxWidth,
462
- width: autoSize ? "auto" : "100%"
463
- };
464
- };
465
- const widthConstraints = getWidthConstraints();
466
- const effectiveDropdownMaxHeight = React3.useMemo(() => {
467
- if (dropdownMaxHeight) return dropdownMaxHeight;
468
- return screenSize === "mobile" ? "70vh" : "60vh";
469
- }, [dropdownMaxHeight, screenSize]);
470
- React3.useEffect(() => {
471
- if (!isPopoverOpen) {
472
- setSearchValue("");
473
- setHighlightedIndex(-1);
474
- }
475
- }, [isPopoverOpen]);
476
- React3.useEffect(() => {
477
- if (isPopoverOpen && searchable && searchInputRef.current) {
478
- const timer = setTimeout(() => {
479
- searchInputRef.current?.focus();
480
- }, 0);
481
- return () => clearTimeout(timer);
482
- }
483
- }, [isPopoverOpen, searchable]);
484
- React3.useEffect(() => {
485
- setHighlightedIndex(flatFilteredOptions.length > 0 ? 0 : -1);
486
- }, [searchValue, flatFilteredOptions.length]);
487
- const totalFilteredCount = React3.useMemo(() => {
488
- if (isGroupedOptions(filteredOptions)) {
489
- return filteredOptions.reduce((acc, group) => acc + group.options.length, 0);
490
- }
491
- return filteredOptions.length;
492
- }, [filteredOptions, isGroupedOptions]);
493
- let optionIndex = 0;
494
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Popover, { open: isPopoverOpen, onOpenChange: setIsPopoverOpen, children: [
495
- /* @__PURE__ */ jsx("div", { id: triggerDescriptionId, className: "sr-only", children: "Multi-select dropdown. Use arrow keys to navigate, Enter to select, and Escape to close." }),
496
- /* @__PURE__ */ jsx("div", { id: selectedCountId, className: "sr-only", "aria-live": "polite", children: selectedValues.length === 0 ? "No options selected" : `${selectedValues.length} option${selectedValues.length === 1 ? "" : "s"} selected: ${selectedValues.map((value) => getOptionByValue(value)?.label).filter(Boolean).join(", ")}` }),
497
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
498
- "button",
499
- {
500
- ref: buttonRef,
501
- type: "button",
502
- ...props,
503
- onClick: (event) => {
504
- if (disabled) return;
505
- onClick?.(event);
506
- handleTogglePopover();
507
- },
508
- disabled,
509
- role: "combobox",
510
- "aria-expanded": isPopoverOpen,
511
- "aria-haspopup": "listbox",
512
- "aria-controls": isPopoverOpen ? listboxId : void 0,
513
- "aria-describedby": `${triggerDescriptionId} ${selectedCountId}`,
514
- "aria-label": `Multi-select: ${selectedValues.length} of ${getAllOptions().length} options selected. ${placeholder}`,
515
- className: cn(
516
- `border-input/70 focus-visible:border-primary/60 focus-visible:ring-primary/20 flex items-center
64
+ const MultiSelect = React$1.forwardRef(({ options, onValueChange, variant, defaultValue = [], placeholder = "Select options", maxCount = 3, className, searchable = true, emptyIndicator, autoSize = false, singleLine = false, popoverClassName, disabled = false, responsive, minWidth, maxWidth, dropdownMaxHeight, deduplicateOptions = false, footerContent, resetOnDefaultValueChange = true, closeOnSelect = false, onClick, ...props }, ref) => {
65
+ const [selectedValues, setSelectedValues] = React$1.useState(defaultValue);
66
+ const [isPopoverOpen, setIsPopoverOpen] = React$1.useState(false);
67
+ const [searchValue, setSearchValue] = React$1.useState("");
68
+ const [highlightedIndex, setHighlightedIndex] = React$1.useState(-1);
69
+ const multiSelectId = React$1.useId();
70
+ const listboxId = `${multiSelectId}-listbox`;
71
+ const triggerDescriptionId = `${multiSelectId}-description`;
72
+ const selectedCountId = `${multiSelectId}-count`;
73
+ const searchInputId = `${multiSelectId}-search`;
74
+ const searchInputRef = React$1.useRef(null);
75
+ const listRef = React$1.useRef(null);
76
+ const prevDefaultValueRef = React$1.useRef(defaultValue);
77
+ const isGroupedOptions = React$1.useCallback((opts) => {
78
+ return opts.length > 0 && "heading" in opts[0];
79
+ }, []);
80
+ const arraysEqual = React$1.useCallback((a, b) => {
81
+ if (a.length !== b.length) return false;
82
+ const sortedA = [...a].sort();
83
+ const sortedB = [...b].sort();
84
+ return sortedA.every((val, index) => val === sortedB[index]);
85
+ }, []);
86
+ const resetToDefault = React$1.useCallback(() => {
87
+ setSelectedValues(defaultValue);
88
+ setIsPopoverOpen(false);
89
+ setSearchValue("");
90
+ onValueChange(defaultValue);
91
+ }, [defaultValue, onValueChange]);
92
+ const buttonRef = React$1.useRef(null);
93
+ React$1.useImperativeHandle(ref, () => ({
94
+ reset: resetToDefault,
95
+ getSelectedValues: () => selectedValues,
96
+ setSelectedValues: (values) => {
97
+ setSelectedValues(values);
98
+ onValueChange(values);
99
+ },
100
+ clear: () => {
101
+ setSelectedValues([]);
102
+ onValueChange([]);
103
+ },
104
+ focus: () => {
105
+ if (buttonRef.current) {
106
+ buttonRef.current.focus();
107
+ const originalOutline = buttonRef.current.style.outline;
108
+ const originalOutlineOffset = buttonRef.current.style.outlineOffset;
109
+ buttonRef.current.style.outline = "2px solid hsl(var(--ring))";
110
+ buttonRef.current.style.outlineOffset = "2px";
111
+ setTimeout(() => {
112
+ if (buttonRef.current) {
113
+ buttonRef.current.style.outline = originalOutline;
114
+ buttonRef.current.style.outlineOffset = originalOutlineOffset;
115
+ }
116
+ }, 1e3);
117
+ }
118
+ }
119
+ }), [
120
+ resetToDefault,
121
+ selectedValues,
122
+ onValueChange
123
+ ]);
124
+ const [screenSize, setScreenSize] = React$1.useState("desktop");
125
+ React$1.useEffect(() => {
126
+ if (typeof window === "undefined") return;
127
+ const handleResize = () => {
128
+ const width = window.innerWidth;
129
+ if (width < 640) setScreenSize("mobile");
130
+ else if (width < 1024) setScreenSize("tablet");
131
+ else setScreenSize("desktop");
132
+ };
133
+ handleResize();
134
+ window.addEventListener("resize", handleResize);
135
+ return () => {
136
+ if (typeof window !== "undefined") window.removeEventListener("resize", handleResize);
137
+ };
138
+ }, []);
139
+ const getResponsiveSettings = () => {
140
+ if (!responsive) return {
141
+ maxCount,
142
+ hideIcons: false,
143
+ compactMode: false
144
+ };
145
+ if (responsive === true) {
146
+ const currentSettings = {
147
+ mobile: {
148
+ maxCount: 2,
149
+ hideIcons: false,
150
+ compactMode: true
151
+ },
152
+ tablet: {
153
+ maxCount: 4,
154
+ hideIcons: false,
155
+ compactMode: false
156
+ },
157
+ desktop: {
158
+ maxCount: 6,
159
+ hideIcons: false,
160
+ compactMode: false
161
+ }
162
+ }[screenSize];
163
+ return {
164
+ maxCount: currentSettings?.maxCount ?? maxCount,
165
+ hideIcons: currentSettings?.hideIcons ?? false,
166
+ compactMode: currentSettings?.compactMode ?? false
167
+ };
168
+ }
169
+ const currentSettings = responsive[screenSize];
170
+ return {
171
+ maxCount: currentSettings?.maxCount ?? maxCount,
172
+ hideIcons: currentSettings?.hideIcons ?? false,
173
+ compactMode: currentSettings?.compactMode ?? false
174
+ };
175
+ };
176
+ const responsiveSettings = getResponsiveSettings();
177
+ const getAllOptions = React$1.useCallback(() => {
178
+ if (options.length === 0) return [];
179
+ let allOptions;
180
+ if (isGroupedOptions(options)) allOptions = options.flatMap((group) => group.options);
181
+ else allOptions = options;
182
+ const valueSet = /* @__PURE__ */ new Set();
183
+ const duplicates = [];
184
+ const uniqueOptions = [];
185
+ allOptions.forEach((option) => {
186
+ if (valueSet.has(option.value)) {
187
+ duplicates.push(option.value);
188
+ if (!deduplicateOptions) uniqueOptions.push(option);
189
+ } else {
190
+ valueSet.add(option.value);
191
+ uniqueOptions.push(option);
192
+ }
193
+ });
194
+ if (process.env.NODE_ENV === "development" && duplicates.length > 0) console.warn(`MultiSelect: Duplicate option values ${deduplicateOptions ? "automatically removed" : "detected"}: ${duplicates.join(", ")}. ${deduplicateOptions ? "Duplicates have been removed automatically." : "This may cause unexpected behavior. Consider setting 'deduplicateOptions={true}' or ensure all option values are unique."}`);
195
+ return deduplicateOptions ? uniqueOptions : allOptions;
196
+ }, [
197
+ options,
198
+ deduplicateOptions,
199
+ isGroupedOptions
200
+ ]);
201
+ const getOptionByValue = React$1.useCallback((value) => {
202
+ const option = getAllOptions().find((option) => option.value === value);
203
+ if (!option && process.env.NODE_ENV === "development") console.warn(`MultiSelect: Option with value "${value}" not found in options list`);
204
+ return option;
205
+ }, [getAllOptions]);
206
+ const filteredOptions = React$1.useMemo(() => {
207
+ if (!searchable || !searchValue) return options;
208
+ if (options.length === 0) return [];
209
+ if (isGroupedOptions(options)) return options.map((group) => ({
210
+ ...group,
211
+ options: group.options.filter((option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase()))
212
+ })).filter((group) => group.options.length > 0);
213
+ return options.filter((option) => option.label.toLowerCase().includes(searchValue.toLowerCase()) || option.value.toLowerCase().includes(searchValue.toLowerCase()));
214
+ }, [
215
+ options,
216
+ searchValue,
217
+ searchable,
218
+ isGroupedOptions
219
+ ]);
220
+ const flatFilteredOptions = React$1.useMemo(() => {
221
+ if (isGroupedOptions(filteredOptions)) return filteredOptions.flatMap((group) => group.options);
222
+ return filteredOptions;
223
+ }, [filteredOptions, isGroupedOptions]);
224
+ const toggleOption = React$1.useCallback((optionValue) => {
225
+ if (disabled) return;
226
+ if (getOptionByValue(optionValue)?.disabled) return;
227
+ const newSelectedValues = selectedValues.includes(optionValue) ? selectedValues.filter((value) => value !== optionValue) : [...selectedValues, optionValue];
228
+ setSelectedValues(newSelectedValues);
229
+ onValueChange(newSelectedValues);
230
+ if (closeOnSelect) setIsPopoverOpen(false);
231
+ }, [
232
+ disabled,
233
+ getOptionByValue,
234
+ selectedValues,
235
+ onValueChange,
236
+ closeOnSelect
237
+ ]);
238
+ const handleClear = () => {
239
+ if (disabled) return;
240
+ setSelectedValues([]);
241
+ onValueChange([]);
242
+ };
243
+ const handleTogglePopover = () => {
244
+ if (disabled) return;
245
+ setIsPopoverOpen((prev) => !prev);
246
+ };
247
+ const clearExtraOptions = () => {
248
+ if (disabled) return;
249
+ const newSelectedValues = selectedValues.slice(0, responsiveSettings.maxCount);
250
+ setSelectedValues(newSelectedValues);
251
+ onValueChange(newSelectedValues);
252
+ };
253
+ const handleKeyDown = React$1.useCallback((event) => {
254
+ const optionsCount = flatFilteredOptions.length;
255
+ if (optionsCount === 0) return;
256
+ switch (event.key) {
257
+ case "ArrowDown":
258
+ event.preventDefault();
259
+ setHighlightedIndex((prev) => prev < optionsCount - 1 ? prev + 1 : 0);
260
+ break;
261
+ case "ArrowUp":
262
+ event.preventDefault();
263
+ setHighlightedIndex((prev) => prev > 0 ? prev - 1 : optionsCount - 1);
264
+ break;
265
+ case "Enter":
266
+ event.preventDefault();
267
+ if (highlightedIndex >= 0 && highlightedIndex < optionsCount) {
268
+ const option = flatFilteredOptions[highlightedIndex];
269
+ if (option && !option.disabled) toggleOption(option.value);
270
+ }
271
+ break;
272
+ case "Escape":
273
+ event.preventDefault();
274
+ setIsPopoverOpen(false);
275
+ break;
276
+ case "Backspace":
277
+ if (!searchValue && selectedValues.length > 0) {
278
+ const newSelectedValues = [...selectedValues];
279
+ newSelectedValues.pop();
280
+ setSelectedValues(newSelectedValues);
281
+ onValueChange(newSelectedValues);
282
+ }
283
+ break;
284
+ }
285
+ }, [
286
+ flatFilteredOptions,
287
+ highlightedIndex,
288
+ toggleOption,
289
+ searchValue,
290
+ selectedValues,
291
+ onValueChange
292
+ ]);
293
+ React$1.useEffect(() => {
294
+ if (!resetOnDefaultValueChange) return;
295
+ const prevDefaultValue = prevDefaultValueRef.current;
296
+ if (!arraysEqual(prevDefaultValue, defaultValue)) {
297
+ if (!arraysEqual(selectedValues, defaultValue)) setSelectedValues(defaultValue);
298
+ prevDefaultValueRef.current = [...defaultValue];
299
+ }
300
+ }, [
301
+ defaultValue,
302
+ selectedValues,
303
+ arraysEqual,
304
+ resetOnDefaultValueChange
305
+ ]);
306
+ const getWidthConstraints = () => {
307
+ return {
308
+ minWidth: minWidth || (screenSize === "mobile" ? "0px" : "200px"),
309
+ maxWidth: maxWidth || "100%",
310
+ width: autoSize ? "auto" : "100%"
311
+ };
312
+ };
313
+ const widthConstraints = getWidthConstraints();
314
+ const effectiveDropdownMaxHeight = React$1.useMemo(() => {
315
+ if (dropdownMaxHeight) return dropdownMaxHeight;
316
+ return screenSize === "mobile" ? "70vh" : "60vh";
317
+ }, [dropdownMaxHeight, screenSize]);
318
+ React$1.useEffect(() => {
319
+ if (!isPopoverOpen) {
320
+ setSearchValue("");
321
+ setHighlightedIndex(-1);
322
+ }
323
+ }, [isPopoverOpen]);
324
+ React$1.useEffect(() => {
325
+ if (isPopoverOpen && searchable && searchInputRef.current) {
326
+ const timer = setTimeout(() => {
327
+ searchInputRef.current?.focus();
328
+ }, 0);
329
+ return () => clearTimeout(timer);
330
+ }
331
+ }, [isPopoverOpen, searchable]);
332
+ React$1.useEffect(() => {
333
+ setHighlightedIndex(flatFilteredOptions.length > 0 ? 0 : -1);
334
+ }, [searchValue, flatFilteredOptions.length]);
335
+ const totalFilteredCount = React$1.useMemo(() => {
336
+ if (isGroupedOptions(filteredOptions)) return filteredOptions.reduce((acc, group) => acc + group.options.length, 0);
337
+ return filteredOptions.length;
338
+ }, [filteredOptions, isGroupedOptions]);
339
+ let optionIndex = 0;
340
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Popover, {
341
+ open: isPopoverOpen,
342
+ onOpenChange: setIsPopoverOpen,
343
+ children: [
344
+ /* @__PURE__ */ jsx("div", {
345
+ id: triggerDescriptionId,
346
+ className: "sr-only",
347
+ children: "Multi-select dropdown. Use arrow keys to navigate, Enter to select, and Escape to close."
348
+ }),
349
+ /* @__PURE__ */ jsx("div", {
350
+ id: selectedCountId,
351
+ className: "sr-only",
352
+ "aria-live": "polite",
353
+ children: selectedValues.length === 0 ? "No options selected" : `${selectedValues.length} option${selectedValues.length === 1 ? "" : "s"} selected: ${selectedValues.map((value) => getOptionByValue(value)?.label).filter(Boolean).join(", ")}`
354
+ }),
355
+ /* @__PURE__ */ jsx(PopoverTrigger, {
356
+ asChild: true,
357
+ children: /* @__PURE__ */ jsx("button", {
358
+ ref: buttonRef,
359
+ type: "button",
360
+ ...props,
361
+ onClick: (event) => {
362
+ if (disabled) return;
363
+ onClick?.(event);
364
+ handleTogglePopover();
365
+ },
366
+ disabled,
367
+ role: "combobox",
368
+ "aria-expanded": isPopoverOpen,
369
+ "aria-haspopup": "listbox",
370
+ "aria-controls": isPopoverOpen ? listboxId : void 0,
371
+ "aria-describedby": `${triggerDescriptionId} ${selectedCountId}`,
372
+ "aria-label": `Multi-select: ${selectedValues.length} of ${getAllOptions().length} options selected. ${placeholder}`,
373
+ className: cn(`border-input/70 focus-visible:border-primary/60 focus-visible:ring-primary/20 flex items-center
517
374
  justify-between rounded-md border bg-transparent pr-1 pl-2 shadow-xs transition-[color,box-shadow,scale]
518
375
  duration-150 ease-out outline-none focus-visible:ring-[3px] motion-safe:active:not-disabled:scale-[0.96]
519
- motion-reduce:transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50`,
520
- singleLine ? "h-8 min-h-8 py-0.5 text-xs" : "h-auto min-h-10 py-2 text-sm",
521
- autoSize && "w-auto",
522
- !autoSize && "w-full",
523
- responsiveSettings.compactMode && "min-h-9 py-1.5 text-xs",
524
- className
525
- ),
526
- style: {
527
- minWidth: widthConstraints.minWidth,
528
- maxWidth: widthConstraints.maxWidth,
529
- width: widthConstraints.width
530
- },
531
- children: selectedValues.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
532
- /* @__PURE__ */ jsxs(
533
- "div",
534
- {
535
- className: cn(
536
- "flex items-center gap-1",
537
- singleLine ? "multiselect-singleline-scroll overflow-x-auto" : "flex-wrap",
538
- responsiveSettings.compactMode && "gap-0.5"
539
- ),
540
- children: [
541
- selectedValues.slice(0, responsiveSettings.maxCount).map((value) => {
542
- const option = getOptionByValue(value);
543
- const IconComponent = option?.icon;
544
- const customStyle = option?.style;
545
- if (!option) {
546
- return null;
547
- }
548
- const badgeStyle = {
549
- ...customStyle?.badgeColor && {
550
- backgroundColor: customStyle.badgeColor
551
- },
552
- ...customStyle?.gradient && {
553
- background: customStyle.gradient,
554
- color: "white"
555
- }
556
- };
557
- return /* @__PURE__ */ jsxs(
558
- Badge,
559
- {
560
- className: cn(
561
- multiSelectVariants({ variant }),
562
- customStyle?.gradient && "border-transparent text-white",
563
- responsiveSettings.compactMode && "px-1.5 py-0.5 text-xs",
564
- singleLine && "py-0.5",
565
- screenSize === "mobile" && "max-w-[120px] truncate",
566
- singleLine && "flex-shrink-0 whitespace-nowrap",
567
- "[&>svg]:pointer-events-auto"
568
- ),
569
- style: badgeStyle,
570
- children: [
571
- IconComponent && !responsiveSettings.hideIcons && /* @__PURE__ */ jsx(
572
- IconComponent,
573
- {
574
- className: cn(
575
- "mr-2 h-4 w-4",
576
- responsiveSettings.compactMode && "mr-1 h-3 w-3",
577
- customStyle?.iconColor && "text-current"
578
- ),
579
- ...customStyle?.iconColor && {
580
- style: { color: customStyle.iconColor }
581
- }
582
- }
583
- ),
584
- /* @__PURE__ */ jsx("span", { className: cn(screenSize === "mobile" && "truncate"), children: option.label }),
585
- /* @__PURE__ */ jsx(
586
- "div",
587
- {
588
- role: "button",
589
- tabIndex: 0,
590
- onClick: (event) => {
591
- event.stopPropagation();
592
- toggleOption(value);
593
- },
594
- onKeyDown: (event) => {
595
- if (event.key === "Enter" || event.key === " ") {
596
- event.preventDefault();
597
- event.stopPropagation();
598
- toggleOption(value);
599
- }
600
- },
601
- "aria-label": `Remove ${option.label} from selection`,
602
- className: "-m-0.5 ml-2 h-4 w-4 cursor-pointer rounded-sm p-0.5 hover:bg-white/20 focus:ring-1 focus:ring-white/50 focus:outline-none",
603
- children: /* @__PURE__ */ jsx(XCircle, { className: cn("h-3 w-3", responsiveSettings.compactMode && "h-2.5 w-2.5") })
604
- }
605
- )
606
- ]
607
- },
608
- value
609
- );
610
- }).filter(Boolean),
611
- selectedValues.length > responsiveSettings.maxCount && /* @__PURE__ */ jsxs(
612
- Badge,
613
- {
614
- className: cn(
615
- "text-foreground border-foreground/10 bg-transparent",
616
- multiSelectVariants({ variant }),
617
- responsiveSettings.compactMode && "px-1.5 py-0.5 text-xs",
618
- singleLine && "flex-shrink-0 whitespace-nowrap",
619
- "[&>svg]:pointer-events-auto"
620
- ),
621
- children: [
622
- `+ ${selectedValues.length - responsiveSettings.maxCount} more`,
623
- /* @__PURE__ */ jsx(
624
- "div",
625
- {
626
- role: "button",
627
- tabIndex: 0,
628
- onClick: (event) => {
629
- event.stopPropagation();
630
- clearExtraOptions();
631
- },
632
- onKeyDown: (event) => {
633
- if (event.key === "Enter" || event.key === " ") {
634
- event.preventDefault();
635
- event.stopPropagation();
636
- clearExtraOptions();
637
- }
638
- },
639
- "aria-label": "Clear extra selected options",
640
- className: "-m-0.5 ml-2 h-4 w-4 cursor-pointer rounded-sm p-0.5 hover:bg-white/20 focus:ring-1\n focus:ring-white/50 focus:outline-none",
641
- children: /* @__PURE__ */ jsx(XCircle, { className: cn("h-3 w-3", responsiveSettings.compactMode && "h-2.5 w-2.5") })
642
- }
643
- )
644
- ]
645
- }
646
- )
647
- ]
648
- }
649
- ),
650
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
651
- /* @__PURE__ */ jsx(
652
- "div",
653
- {
654
- role: "button",
655
- tabIndex: 0,
656
- onClick: (event) => {
657
- event.stopPropagation();
658
- handleClear();
659
- },
660
- onKeyDown: (event) => {
661
- if (event.key === "Enter" || event.key === " ") {
662
- event.preventDefault();
663
- event.stopPropagation();
664
- handleClear();
665
- }
666
- },
667
- "aria-label": `Clear all ${selectedValues.length} selected options`,
668
- className: "text-muted-foreground hover:text-foreground focus:ring-ring mx-2 flex h-4 w-4\n cursor-pointer items-center justify-center rounded-sm focus:ring-2 focus:ring-offset-1\n focus:outline-none",
669
- children: /* @__PURE__ */ jsx(XIcon, { className: "h-4 w-4" })
670
- }
671
- ),
672
- /* @__PURE__ */ jsx(Separator, { orientation: "vertical", className: "flex h-full min-h-6" }),
673
- /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground mx-1 h-4 cursor-pointer" })
674
- ] })
675
- ] }) : /* @__PURE__ */ jsxs("div", { className: "mx-auto flex w-full items-center justify-between", children: [
676
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground mx-1 text-sm", children: placeholder }),
677
- /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground mx-1 h-4 cursor-pointer" })
678
- ] })
679
- }
680
- ) }),
681
- /* @__PURE__ */ jsx(
682
- PopoverContent,
683
- {
684
- id: listboxId,
685
- "aria-label": "Available options",
686
- className: cn("w-(--anchor-width) overflow-hidden p-0", popoverClassName),
687
- style: {
688
- minWidth: widthConstraints.minWidth,
689
- maxWidth: widthConstraints.maxWidth,
690
- width: widthConstraints.width === "auto" ? "auto" : void 0,
691
- maxHeight: effectiveDropdownMaxHeight,
692
- touchAction: "manipulation"
693
- },
694
- align: "start",
695
- onEscapeKeyDown: () => setIsPopoverOpen(false),
696
- children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-[inherit] flex-col", onKeyDown: handleKeyDown, children: [
697
- searchable && /* @__PURE__ */ jsxs("div", { className: "flex items-center border-b px-3", children: [
698
- /* @__PURE__ */ jsx(SearchIcon, { className: "text-muted-foreground mr-2 h-4 w-4 shrink-0 opacity-50" }),
699
- /* @__PURE__ */ jsx(
700
- "input",
701
- {
702
- ref: searchInputRef,
703
- id: searchInputId,
704
- type: "text",
705
- placeholder: "Search options...",
706
- value: searchValue,
707
- onChange: (e) => setSearchValue(e.target.value),
708
- "aria-label": "Search through available options",
709
- className: "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50"
710
- }
711
- )
712
- ] }),
713
- /* @__PURE__ */ jsx(
714
- "div",
715
- {
716
- ref: listRef,
717
- role: "listbox",
718
- "aria-multiselectable": "true",
719
- className: "multiselect-scrollbar scrollbar-neutral-thin overscroll-contain min-h-0 flex-1 overflow-y-auto p-1",
720
- children: totalFilteredCount === 0 ? /* @__PURE__ */ jsx("div", { className: "text-muted-foreground py-6 text-center text-sm", children: emptyIndicator || "No results found." }) : isGroupedOptions(filteredOptions) ? filteredOptions.map((group) => /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": `group-${group.heading}`, children: [
721
- /* @__PURE__ */ jsx(
722
- "div",
723
- {
724
- id: `group-${group.heading}`,
725
- className: "text-muted-foreground px-2 py-1.5 text-xs font-medium",
726
- children: group.heading
727
- }
728
- ),
729
- group.options.map((option) => {
730
- const currentIndex = optionIndex++;
731
- const isSelected = selectedValues.includes(option.value);
732
- return /* @__PURE__ */ jsx(
733
- OptionItem,
734
- {
735
- option,
736
- isSelected,
737
- onSelect: () => toggleOption(option.value),
738
- highlightedIndex,
739
- index: currentIndex,
740
- setHighlightedIndex
741
- },
742
- option.value
743
- );
744
- })
745
- ] }, group.heading)) : filteredOptions.map((option) => {
746
- const currentIndex = optionIndex++;
747
- const isSelected = selectedValues.includes(option.value);
748
- return /* @__PURE__ */ jsx(
749
- OptionItem,
750
- {
751
- option,
752
- isSelected,
753
- onSelect: () => toggleOption(option.value),
754
- highlightedIndex,
755
- index: currentIndex,
756
- setHighlightedIndex
757
- },
758
- option.value
759
- );
760
- })
761
- }
762
- ),
763
- footerContent && /* @__PURE__ */ jsx("div", { className: "border-t p-1", children: footerContent })
764
- ] })
765
- }
766
- )
767
- ] }) });
768
- }
769
- );
376
+ motion-reduce:transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50`, singleLine ? "h-8 min-h-8 py-0.5 text-xs" : "h-auto min-h-10 py-2 text-sm", autoSize && "w-auto", !autoSize && "w-full", responsiveSettings.compactMode && "min-h-9 py-1.5 text-xs", className),
377
+ style: {
378
+ minWidth: widthConstraints.minWidth,
379
+ maxWidth: widthConstraints.maxWidth,
380
+ width: widthConstraints.width
381
+ },
382
+ children: selectedValues.length > 0 ? /* @__PURE__ */ jsxs("div", {
383
+ className: "flex w-full items-center justify-between",
384
+ children: [/* @__PURE__ */ jsxs("div", {
385
+ className: cn("flex items-center gap-1", singleLine ? "multiselect-singleline-scroll overflow-x-auto" : "flex-wrap", responsiveSettings.compactMode && "gap-0.5"),
386
+ children: [selectedValues.slice(0, responsiveSettings.maxCount).map((value) => {
387
+ const option = getOptionByValue(value);
388
+ const IconComponent = option?.icon;
389
+ const customStyle = option?.style;
390
+ if (!option) return null;
391
+ const badgeStyle = {
392
+ ...customStyle?.badgeColor && { backgroundColor: customStyle.badgeColor },
393
+ ...customStyle?.gradient && {
394
+ background: customStyle.gradient,
395
+ color: "white"
396
+ }
397
+ };
398
+ return /* @__PURE__ */ jsxs(Badge, {
399
+ className: cn(multiSelectVariants({ variant }), customStyle?.gradient && "border-transparent text-white", responsiveSettings.compactMode && "px-1.5 py-0.5 text-xs", singleLine && "py-0.5", screenSize === "mobile" && "max-w-[120px] truncate", singleLine && "flex-shrink-0 whitespace-nowrap", "[&>svg]:pointer-events-auto"),
400
+ style: badgeStyle,
401
+ children: [
402
+ IconComponent && !responsiveSettings.hideIcons && /* @__PURE__ */ jsx(IconComponent, {
403
+ className: cn("mr-2 h-4 w-4", responsiveSettings.compactMode && "mr-1 h-3 w-3", customStyle?.iconColor && "text-current"),
404
+ ...customStyle?.iconColor && { style: { color: customStyle.iconColor } }
405
+ }),
406
+ /* @__PURE__ */ jsx("span", {
407
+ className: cn(screenSize === "mobile" && "truncate"),
408
+ children: option.label
409
+ }),
410
+ /* @__PURE__ */ jsx("div", {
411
+ role: "button",
412
+ tabIndex: 0,
413
+ onClick: (event) => {
414
+ event.stopPropagation();
415
+ toggleOption(value);
416
+ },
417
+ onKeyDown: (event) => {
418
+ if (event.key === "Enter" || event.key === " ") {
419
+ event.preventDefault();
420
+ event.stopPropagation();
421
+ toggleOption(value);
422
+ }
423
+ },
424
+ "aria-label": `Remove ${option.label} from selection`,
425
+ className: "-m-0.5 ml-2 h-4 w-4 cursor-pointer rounded-sm p-0.5 hover:bg-white/20 focus:ring-1 focus:ring-white/50 focus:outline-none",
426
+ children: /* @__PURE__ */ jsx(XCircle, { className: cn("h-3 w-3", responsiveSettings.compactMode && "h-2.5 w-2.5") })
427
+ })
428
+ ]
429
+ }, value);
430
+ }).filter(Boolean), selectedValues.length > responsiveSettings.maxCount && /* @__PURE__ */ jsxs(Badge, {
431
+ className: cn("text-foreground border-foreground/10 bg-transparent", multiSelectVariants({ variant }), responsiveSettings.compactMode && "px-1.5 py-0.5 text-xs", singleLine && "flex-shrink-0 whitespace-nowrap", "[&>svg]:pointer-events-auto"),
432
+ children: [`+ ${selectedValues.length - responsiveSettings.maxCount} more`, /* @__PURE__ */ jsx("div", {
433
+ role: "button",
434
+ tabIndex: 0,
435
+ onClick: (event) => {
436
+ event.stopPropagation();
437
+ clearExtraOptions();
438
+ },
439
+ onKeyDown: (event) => {
440
+ if (event.key === "Enter" || event.key === " ") {
441
+ event.preventDefault();
442
+ event.stopPropagation();
443
+ clearExtraOptions();
444
+ }
445
+ },
446
+ "aria-label": "Clear extra selected options",
447
+ className: "-m-0.5 ml-2 h-4 w-4 cursor-pointer rounded-sm p-0.5 hover:bg-white/20 focus:ring-1\n focus:ring-white/50 focus:outline-none",
448
+ children: /* @__PURE__ */ jsx(XCircle, { className: cn("h-3 w-3", responsiveSettings.compactMode && "h-2.5 w-2.5") })
449
+ })]
450
+ })]
451
+ }), /* @__PURE__ */ jsxs("div", {
452
+ className: "flex items-center justify-between",
453
+ children: [
454
+ /* @__PURE__ */ jsx("div", {
455
+ role: "button",
456
+ tabIndex: 0,
457
+ onClick: (event) => {
458
+ event.stopPropagation();
459
+ handleClear();
460
+ },
461
+ onKeyDown: (event) => {
462
+ if (event.key === "Enter" || event.key === " ") {
463
+ event.preventDefault();
464
+ event.stopPropagation();
465
+ handleClear();
466
+ }
467
+ },
468
+ "aria-label": `Clear all ${selectedValues.length} selected options`,
469
+ className: "text-muted-foreground hover:text-foreground focus:ring-ring mx-2 flex h-4 w-4\n cursor-pointer items-center justify-center rounded-sm focus:ring-2 focus:ring-offset-1\n focus:outline-none",
470
+ children: /* @__PURE__ */ jsx(XIcon, { className: "h-4 w-4" })
471
+ }),
472
+ /* @__PURE__ */ jsx(Separator, {
473
+ orientation: "vertical",
474
+ className: "flex h-full min-h-6"
475
+ }),
476
+ /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground mx-1 h-4 cursor-pointer" })
477
+ ]
478
+ })]
479
+ }) : /* @__PURE__ */ jsxs("div", {
480
+ className: "mx-auto flex w-full items-center justify-between",
481
+ children: [/* @__PURE__ */ jsx("span", {
482
+ className: "text-muted-foreground mx-1 text-sm",
483
+ children: placeholder
484
+ }), /* @__PURE__ */ jsx(ChevronDown, { className: "text-muted-foreground mx-1 h-4 cursor-pointer" })]
485
+ })
486
+ })
487
+ }),
488
+ /* @__PURE__ */ jsx(PopoverContent, {
489
+ id: listboxId,
490
+ "aria-label": "Available options",
491
+ className: cn("w-(--anchor-width) overflow-hidden p-0", popoverClassName),
492
+ style: {
493
+ minWidth: widthConstraints.minWidth,
494
+ maxWidth: widthConstraints.maxWidth,
495
+ width: widthConstraints.width === "auto" ? "auto" : void 0,
496
+ maxHeight: effectiveDropdownMaxHeight,
497
+ touchAction: "manipulation"
498
+ },
499
+ align: "start",
500
+ onEscapeKeyDown: () => setIsPopoverOpen(false),
501
+ children: /* @__PURE__ */ jsxs("div", {
502
+ className: "flex h-full max-h-[inherit] flex-col",
503
+ onKeyDown: handleKeyDown,
504
+ children: [
505
+ searchable && /* @__PURE__ */ jsxs("div", {
506
+ className: "flex items-center border-b px-3",
507
+ children: [/* @__PURE__ */ jsx(SearchIcon, { className: "text-muted-foreground mr-2 h-4 w-4 shrink-0 opacity-50" }), /* @__PURE__ */ jsx("input", {
508
+ ref: searchInputRef,
509
+ id: searchInputId,
510
+ type: "text",
511
+ placeholder: "Search options...",
512
+ value: searchValue,
513
+ onChange: (e) => setSearchValue(e.target.value),
514
+ "aria-label": "Search through available options",
515
+ className: "placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50"
516
+ })]
517
+ }),
518
+ /* @__PURE__ */ jsx("div", {
519
+ ref: listRef,
520
+ role: "listbox",
521
+ "aria-multiselectable": "true",
522
+ className: "multiselect-scrollbar scrollbar-neutral-thin overscroll-contain min-h-0 flex-1 overflow-y-auto p-1",
523
+ children: totalFilteredCount === 0 ? /* @__PURE__ */ jsx("div", {
524
+ className: "text-muted-foreground py-6 text-center text-sm",
525
+ children: emptyIndicator || "No results found."
526
+ }) : isGroupedOptions(filteredOptions) ? filteredOptions.map((group) => /* @__PURE__ */ jsxs("div", {
527
+ role: "group",
528
+ "aria-labelledby": `group-${group.heading}`,
529
+ children: [/* @__PURE__ */ jsx("div", {
530
+ id: `group-${group.heading}`,
531
+ className: "text-muted-foreground px-2 py-1.5 text-xs font-medium",
532
+ children: group.heading
533
+ }), group.options.map((option) => {
534
+ const currentIndex = optionIndex++;
535
+ return /* @__PURE__ */ jsx(OptionItem, {
536
+ option,
537
+ isSelected: selectedValues.includes(option.value),
538
+ onSelect: () => toggleOption(option.value),
539
+ highlightedIndex,
540
+ index: currentIndex,
541
+ setHighlightedIndex
542
+ }, option.value);
543
+ })]
544
+ }, group.heading)) : filteredOptions.map((option) => {
545
+ const currentIndex = optionIndex++;
546
+ return /* @__PURE__ */ jsx(OptionItem, {
547
+ option,
548
+ isSelected: selectedValues.includes(option.value),
549
+ onSelect: () => toggleOption(option.value),
550
+ highlightedIndex,
551
+ index: currentIndex,
552
+ setHighlightedIndex
553
+ }, option.value);
554
+ })
555
+ }),
556
+ footerContent && /* @__PURE__ */ jsx("div", {
557
+ className: "border-t p-1",
558
+ children: footerContent
559
+ })
560
+ ]
561
+ })
562
+ })
563
+ ]
564
+ }) });
565
+ });
770
566
  MultiSelect.displayName = "MultiSelect";
771
567
 
568
+ //#endregion
772
569
  export { MultiSelect };
773
- //# sourceMappingURL=multi-select.js.map
774
570
  //# sourceMappingURL=multi-select.js.map