@keboola/design 11.9.0 → 12.0.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 (363) hide show
  1. package/AGENTS.md +34 -8
  2. package/CHANGELOG.md +155 -0
  3. package/COMPONENT-API.md +337 -289
  4. package/README.md +11 -1
  5. package/dist/{AIKit-ELIsegJz.js → AIKit-BD4r7ff-.js} +404 -243
  6. package/dist/AIKit-BD4r7ff-.js.map +1 -0
  7. package/dist/{Alert-BsIM_oFK.js → Alert-UI-CIs-1.js} +16 -16
  8. package/dist/Alert-UI-CIs-1.js.map +1 -0
  9. package/dist/{AlertModal-BGJdaRRj.js → AlertModal-Th2khjPi.js} +5 -5
  10. package/dist/AlertModal-Th2khjPi.js.map +1 -0
  11. package/dist/{AppShell-DRgJxpXW.js → AppShell-WSQabK8r.js} +15 -52
  12. package/dist/AppShell-WSQabK8r.js.map +1 -0
  13. package/dist/{AutoSaveTextarea-BeuWuszr.js → AutoSaveTextarea-C5iIr2Ts.js} +2 -2
  14. package/dist/{AutoSaveTextarea-BeuWuszr.js.map → AutoSaveTextarea-C5iIr2Ts.js.map} +1 -1
  15. package/dist/{Badge-o5jURtpB.js → Badge-DIjhwPvh.js} +4 -9
  16. package/dist/Badge-DIjhwPvh.js.map +1 -0
  17. package/dist/{BrandEditor-BsTBM3s6.js → BrandEditor-BU23Vl8V.js} +7 -7
  18. package/dist/{BrandEditor-BsTBM3s6.js.map → BrandEditor-BU23Vl8V.js.map} +1 -1
  19. package/dist/{BrandLogo-CoKBk4MI.js → BrandLogo-CKpVSZb6.js} +4 -4
  20. package/dist/BrandLogo-CKpVSZb6.js.map +1 -0
  21. package/dist/{Breadcrumb-xqEUxfwn.js → Breadcrumb-p9HtMLCc.js} +8 -14
  22. package/dist/Breadcrumb-p9HtMLCc.js.map +1 -0
  23. package/dist/{Button-DsRrU5F1.js → Button-Ca4Q3VJU.js} +31 -13
  24. package/dist/Button-Ca4Q3VJU.js.map +1 -0
  25. package/dist/{Calendar-cG5NIJ4O.js → Calendar-DFtmZzbF.js} +99 -99
  26. package/dist/Calendar-DFtmZzbF.js.map +1 -0
  27. package/dist/{Card-Dyo7055Q.js → Card-Cr9MBNHu.js} +4 -4
  28. package/dist/Card-Cr9MBNHu.js.map +1 -0
  29. package/dist/{Checkbox-Dq5fPNrO.js → Checkbox-8yIIgY7g.js} +4 -4
  30. package/dist/Checkbox-8yIIgY7g.js.map +1 -0
  31. package/dist/{Clipboard-BZitKiSA.js → Clipboard-_xf6hMDD.js} +2 -2
  32. package/dist/{Clipboard-BZitKiSA.js.map → Clipboard-_xf6hMDD.js.map} +1 -1
  33. package/dist/{ClipboardButton-KHQnPEh_.js → ClipboardButton-DHa1trtI.js} +4 -4
  34. package/dist/{ClipboardButton-KHQnPEh_.js.map → ClipboardButton-DHa1trtI.js.map} +1 -1
  35. package/dist/{CodeEditor-BJKJXA0c.js → CodeEditor-BSo-oLFG.js} +55 -165
  36. package/dist/CodeEditor-BSo-oLFG.js.map +1 -0
  37. package/dist/{ColorInput-Bj3dfPFA.js → ColorInput-DSMqrs2-.js} +12 -27
  38. package/dist/ColorInput-DSMqrs2-.js.map +1 -0
  39. package/dist/{ColorModeSwitch-CWt-DZGC.js → ColorModeSwitch-D7EuWyJz.js} +7 -17
  40. package/dist/ColorModeSwitch-D7EuWyJz.js.map +1 -0
  41. package/dist/Combobox-CxRAYOBt.js +1069 -0
  42. package/dist/Combobox-CxRAYOBt.js.map +1 -0
  43. package/dist/{Command-BDU3C1gg.js → Command-BU_cVurn.js} +4 -4
  44. package/dist/{Command-BDU3C1gg.js.map → Command-BU_cVurn.js.map} +1 -1
  45. package/dist/{CopyField-BHRQUyuF.js → CopyField-6_c-NdLO.js} +17 -53
  46. package/dist/{CopyField-BHRQUyuF.js.map → CopyField-6_c-NdLO.js.map} +1 -1
  47. package/dist/{DateInput-B6N8g0ra.js → DateInput-DyEErfJf.js} +6 -6
  48. package/dist/{DateInput-B6N8g0ra.js.map → DateInput-DyEErfJf.js.map} +1 -1
  49. package/dist/{DatePicker-nA8YdE84.js → DatePicker-CtSa9b3V.js} +3 -3
  50. package/dist/{DatePicker-nA8YdE84.js.map → DatePicker-CtSa9b3V.js.map} +1 -1
  51. package/dist/{DateRangeInput-7M9Z4cVO.js → DateRangeInput-Dg7-VUd9.js} +10 -14
  52. package/dist/DateRangeInput-Dg7-VUd9.js.map +1 -0
  53. package/dist/{DateRangePicker-DjSUFjh4.js → DateRangePicker-BoPnh4aH.js} +9 -13
  54. package/dist/DateRangePicker-BoPnh4aH.js.map +1 -0
  55. package/dist/DiffView-ppTIzh2h.js.map +1 -1
  56. package/dist/{DropdownMenu-CgVwhDvl.js → DropdownMenu-gRM-A8qU.js} +3 -3
  57. package/dist/DropdownMenu-gRM-A8qU.js.map +1 -0
  58. package/dist/{FieldItem-DZGIdiXE.js → FieldItem-2wMXQ0Qw.js} +12 -25
  59. package/dist/FieldItem-2wMXQ0Qw.js.map +1 -0
  60. package/dist/{FieldItem-vhIJW4pj.d.ts → FieldItem-CPN1xjN5.d.ts} +11 -25
  61. package/dist/{FileUpload-DYQCTGjU.js → FileUpload-C83tXuE2.js} +11 -16
  62. package/dist/{FileUpload-DYQCTGjU.js.map → FileUpload-C83tXuE2.js.map} +1 -1
  63. package/dist/{Form-CcK7dRrC.js → Form-95rVLfX8.js} +15 -23
  64. package/dist/{Form-CcK7dRrC.js.map → Form-95rVLfX8.js.map} +1 -1
  65. package/dist/{FormGroup-DR_gZ25-.js → FormGroup-CmNiAtU6.js} +11 -17
  66. package/dist/FormGroup-CmNiAtU6.js.map +1 -0
  67. package/dist/{FullScreenModal-CN9nAs72.js → FullScreenModal-CD7mYeTz.js} +15 -29
  68. package/dist/FullScreenModal-CD7mYeTz.js.map +1 -0
  69. package/dist/{HoverCard-B9ZMJxjn.js → HoverCard-B8OKu9XZ.js} +2 -2
  70. package/dist/{HoverCard-B9ZMJxjn.js.map → HoverCard-B8OKu9XZ.js.map} +1 -1
  71. package/dist/{InputGroup-Do8K2hvD.js → InputGroup-B4QOPxHl.js} +11 -13
  72. package/dist/InputGroup-B4QOPxHl.js.map +1 -0
  73. package/dist/{Kbd-LCFMumoq.js → Kbd-J4n1J6i4.js} +23 -13
  74. package/dist/Kbd-J4n1J6i4.js.map +1 -0
  75. package/dist/{MarkedText-DNGEUVWc.js → MarkedText-DlmlJO0u.js} +2 -2
  76. package/dist/{MarkedText-DNGEUVWc.js.map → MarkedText-DlmlJO0u.js.map} +1 -1
  77. package/dist/{MermaidDiagram-ZG0iiDV_.js → MermaidDiagram-BQvz6bhv.js} +16 -34
  78. package/dist/MermaidDiagram-BQvz6bhv.js.map +1 -0
  79. package/dist/{Modal-I3VWk2oo.js → Modal-Driyqs_N.js} +17 -34
  80. package/dist/Modal-Driyqs_N.js.map +1 -0
  81. package/dist/{ModalTitle-CeLM_mX9.js → ModalTitle-BxopkIoQ.js} +3 -3
  82. package/dist/ModalTitle-BxopkIoQ.js.map +1 -0
  83. package/dist/{MultiActionButtonGroup-CYZ8IgSf.js → MultiActionButtonGroup-BPnmzBtw.js} +3 -3
  84. package/dist/{MultiActionButtonGroup-CYZ8IgSf.js.map → MultiActionButtonGroup-BPnmzBtw.js.map} +1 -1
  85. package/dist/{Navbar-Liy1TPI7.js → Navbar-B_DNpv5s.js} +9 -13
  86. package/dist/{Navbar-Liy1TPI7.js.map → Navbar-B_DNpv5s.js.map} +1 -1
  87. package/dist/{OtpInput-CbbymqYs.js → OtpInput-I8B8Vjdl.js} +2 -2
  88. package/dist/{OtpInput-CbbymqYs.js.map → OtpInput-I8B8Vjdl.js.map} +1 -1
  89. package/dist/{PageHeader-Q3IpCnQd.js → PageHeader-CgfyXpf1.js} +13 -26
  90. package/dist/PageHeader-CgfyXpf1.js.map +1 -0
  91. package/dist/{PageLayout-DSVM-ASz.js → PageLayout-DiAAILuS.js} +12 -20
  92. package/dist/PageLayout-DiAAILuS.js.map +1 -0
  93. package/dist/{PageToolbar-BKVJiDAL.js → PageToolbar-DOAtAnfL.js} +12 -42
  94. package/dist/PageToolbar-DOAtAnfL.js.map +1 -0
  95. package/dist/{Pagination-C_b7Xhey.js → Pagination-LaSg-5cl.js} +3 -3
  96. package/dist/{Pagination-C_b7Xhey.js.map → Pagination-LaSg-5cl.js.map} +1 -1
  97. package/dist/{Popconfirm-5pBzT_HQ.js → Popconfirm-SLz0zodk.js} +3 -3
  98. package/dist/{Popconfirm-5pBzT_HQ.js.map → Popconfirm-SLz0zodk.js.map} +1 -1
  99. package/dist/{Popover-BEbQrC_P.js → Popover-CEk915I1.js} +4 -3
  100. package/dist/Popover-CEk915I1.js.map +1 -0
  101. package/dist/{RadioGroup-Byc2mym4.js → RadioGroup-CBPRLRN0.js} +4 -4
  102. package/dist/{RadioGroup-Byc2mym4.js.map → RadioGroup-CBPRLRN0.js.map} +1 -1
  103. package/dist/{Search-Dhig_hPD.js → Search-DmkQo716.js} +3 -3
  104. package/dist/{Search-Dhig_hPD.js.map → Search-DmkQo716.js.map} +1 -1
  105. package/dist/{SearchInput-92r2bkA7.js → SearchInput-CEfQDNl3.js} +8 -13
  106. package/dist/SearchInput-CEfQDNl3.js.map +1 -0
  107. package/dist/{SectionNav-CNLJsiVG.js → SectionNav-B_qf0AXi.js} +10 -42
  108. package/dist/SectionNav-B_qf0AXi.js.map +1 -0
  109. package/dist/{Select-DV3Hak_l.js → Select-ByRvkZ3D.js} +8 -11
  110. package/dist/{Select-DV3Hak_l.js.map → Select-ByRvkZ3D.js.map} +1 -1
  111. package/dist/{Sheet-OparjIi-.js → Sheet-C-yXk5Da.js} +5 -9
  112. package/dist/Sheet-C-yXk5Da.js.map +1 -0
  113. package/dist/{Sidebar-CLEbBtNY.js → Sidebar-Ds0E6PbR.js} +16 -33
  114. package/dist/Sidebar-Ds0E6PbR.js.map +1 -0
  115. package/dist/{Slider-DLclvRws.js → Slider-DWdu9NuM.js} +3 -3
  116. package/dist/{Slider-DLclvRws.js.map → Slider-DWdu9NuM.js.map} +1 -1
  117. package/dist/{Stepper-C8sm9ZFM.js → Stepper-BLkLhfnd.js} +6 -9
  118. package/dist/{Stepper-C8sm9ZFM.js.map → Stepper-BLkLhfnd.js.map} +1 -1
  119. package/dist/{Switch-B0WdGSjz.js → Switch-DZvNePOm.js} +2 -2
  120. package/dist/{Switch-B0WdGSjz.js.map → Switch-DZvNePOm.js.map} +1 -1
  121. package/dist/{Table-CvYuTuNU.js → Table-BaVT5Tkn.js} +6 -11
  122. package/dist/{Table-CvYuTuNU.js.map → Table-BaVT5Tkn.js.map} +1 -1
  123. package/dist/{Tabs-eB974xJf.js → Tabs-Dt9oLYHC.js} +3 -3
  124. package/dist/{Tabs-eB974xJf.js.map → Tabs-Dt9oLYHC.js.map} +1 -1
  125. package/dist/{TextInput-CFTf4Cz1.js → TextInput-CDG2XpBl.js} +10 -14
  126. package/dist/TextInput-CDG2XpBl.js.map +1 -0
  127. package/dist/{ThemeProvider-DAmNn9Sd.js → ThemeProvider-DXsxFg1U.js} +13 -31
  128. package/dist/ThemeProvider-DXsxFg1U.js.map +1 -0
  129. package/dist/{TimePicker-BGeqc-Ed.js → TimePicker-CDGYrRxi.js} +2 -2
  130. package/dist/{TimePicker-BGeqc-Ed.js.map → TimePicker-CDGYrRxi.js.map} +1 -1
  131. package/dist/{Timeline-C8-wnRRr.js → Timeline-B-I6sb0M.js} +2 -2
  132. package/dist/{Timeline-C8-wnRRr.js.map → Timeline-B-I6sb0M.js.map} +1 -1
  133. package/dist/{Toast-Dr6Uw7ao.js → Toast-PfQf3vj-.js} +2 -2
  134. package/dist/{Toast-Dr6Uw7ao.js.map → Toast-PfQf3vj-.js.map} +1 -1
  135. package/dist/{Workbench-UR2FBC7I.js → Workbench-DmZzpkj7.js} +2 -2
  136. package/dist/{Workbench-UR2FBC7I.js.map → Workbench-DmZzpkj7.js.map} +1 -1
  137. package/dist/{ZoomableSvg-BZlk3PFJ.js → ZoomableSvg-BzXVfgnI.js} +5 -19
  138. package/dist/ZoomableSvg-BzXVfgnI.js.map +1 -0
  139. package/dist/charts.d.ts +21 -52
  140. package/dist/charts.js +13 -39
  141. package/dist/charts.js.map +1 -1
  142. package/dist/{context-D7X470dy.js → context-U293r3v-.js} +5 -9
  143. package/dist/context-U293r3v-.js.map +1 -0
  144. package/dist/editors.d.ts +27 -124
  145. package/dist/editors.js +29 -71
  146. package/dist/editors.js.map +1 -1
  147. package/dist/{findLiteralMatches-BGBw8Vbl.js → findLiteralMatches-DgGLzyG0.js} +8 -20
  148. package/dist/findLiteralMatches-DgGLzyG0.js.map +1 -0
  149. package/dist/flint.d.ts +3 -6
  150. package/dist/flint.js +31 -80
  151. package/dist/flint.js.map +1 -1
  152. package/dist/{icons-Cek151jC.js → icons-wcA70iQx.js} +105 -2
  153. package/dist/icons-wcA70iQx.js.map +1 -0
  154. package/dist/icons.d.ts +2 -2
  155. package/dist/icons.js +2 -2
  156. package/dist/{index-m-kQEWiY.d.ts → index-B7k-09i1.d.ts} +14 -2
  157. package/dist/index.d.ts +1151 -1838
  158. package/dist/index.js +68 -67
  159. package/dist/internal/blocks/AIKit.js +2 -2
  160. package/dist/internal/blocks/AppShell.js +1 -1
  161. package/dist/internal/blocks/AuthLayout.js +7 -27
  162. package/dist/internal/blocks/AuthLayout.js.map +1 -1
  163. package/dist/internal/blocks/AutoSaveTextarea.js +1 -1
  164. package/dist/internal/blocks/BrandEditor.js +1 -1
  165. package/dist/internal/blocks/ChartPanel.js +4 -8
  166. package/dist/internal/blocks/ChartPanel.js.map +1 -1
  167. package/dist/internal/blocks/ChipEditor.js +13 -21
  168. package/dist/internal/blocks/ChipEditor.js.map +1 -1
  169. package/dist/internal/blocks/ClipboardButton.js +1 -1
  170. package/dist/internal/blocks/ColorInput.js +1 -1
  171. package/dist/internal/blocks/ColorModeSwitch.js +1 -1
  172. package/dist/internal/blocks/Command.js +1 -1
  173. package/dist/internal/blocks/CopyField.js +1 -1
  174. package/dist/internal/blocks/DashboardHero.js +4 -7
  175. package/dist/internal/blocks/DashboardHero.js.map +1 -1
  176. package/dist/internal/blocks/DateInput.js +1 -1
  177. package/dist/internal/blocks/DateRangeInput.js +1 -1
  178. package/dist/internal/blocks/EmptyConfigurationActionCard.js +1 -1
  179. package/dist/internal/blocks/EmptyState.js +5 -9
  180. package/dist/internal/blocks/EmptyState.js.map +1 -1
  181. package/dist/internal/blocks/ErrorState.js +5 -9
  182. package/dist/internal/blocks/ErrorState.js.map +1 -1
  183. package/dist/internal/blocks/ExportMenu.js +6 -10
  184. package/dist/internal/blocks/ExportMenu.js.map +1 -1
  185. package/dist/internal/blocks/Form/connectors/ComboboxField.js +40 -0
  186. package/dist/internal/blocks/Form/connectors/ComboboxField.js.map +1 -0
  187. package/dist/internal/blocks/Form/connectors/MultiComboboxField.js +5 -22
  188. package/dist/internal/blocks/Form/connectors/MultiComboboxField.js.map +1 -1
  189. package/dist/internal/blocks/Form.js +1 -1
  190. package/dist/internal/blocks/FormGroup.js +1 -1
  191. package/dist/internal/blocks/GoogleButton.js +1 -1
  192. package/dist/internal/blocks/MicrosoftButton.js +1 -1
  193. package/dist/internal/blocks/MultiActionButtonGroup.js +1 -1
  194. package/dist/internal/blocks/MultiCombobox.js +161 -154
  195. package/dist/internal/blocks/MultiCombobox.js.map +1 -1
  196. package/dist/internal/blocks/NumberInput.js +1 -1
  197. package/dist/internal/blocks/OtpInput.js +1 -1
  198. package/dist/internal/blocks/PageHeader.js +1 -1
  199. package/dist/internal/blocks/PageLayout.js +1 -1
  200. package/dist/internal/blocks/PageToolbar.js +1 -1
  201. package/dist/internal/blocks/PasswordInput.js +4 -4
  202. package/dist/internal/blocks/PasswordInput.js.map +1 -1
  203. package/dist/internal/blocks/SearchInput.js +1 -1
  204. package/dist/internal/blocks/SearchInputWithNavigation.js +4 -4
  205. package/dist/internal/blocks/SectionNav.js +1 -1
  206. package/dist/internal/blocks/SplitButton.js +3 -3
  207. package/dist/internal/blocks/StatCard.js +4 -8
  208. package/dist/internal/blocks/StatCard.js.map +1 -1
  209. package/dist/internal/blocks/TextInput.js +1 -1
  210. package/dist/internal/blocks/Textarea.js +2 -2
  211. package/dist/internal/blocks/TimeInput.js +5 -5
  212. package/dist/internal/blocks/TimeInput.js.map +1 -1
  213. package/dist/internal/components/Alert.js +1 -1
  214. package/dist/internal/components/AlertModal.js +1 -1
  215. package/dist/internal/components/Avatar.js +1 -1
  216. package/dist/internal/components/Badge.js +1 -1
  217. package/dist/internal/components/BrandLogo.js +1 -1
  218. package/dist/internal/components/Breadcrumb.js +1 -1
  219. package/dist/internal/components/Button.js +1 -1
  220. package/dist/internal/components/ButtonGroup.js.map +1 -1
  221. package/dist/internal/components/Calendar.js +1 -1
  222. package/dist/internal/components/Card.js +1 -1
  223. package/dist/internal/components/Checkbox.js +1 -1
  224. package/dist/internal/components/Clipboard.js +1 -1
  225. package/dist/internal/components/CollapsiblePanel.js +2 -2
  226. package/dist/internal/components/Combobox.js +2 -2
  227. package/dist/internal/components/DatePicker.js +1 -1
  228. package/dist/internal/components/DateRangePicker.js +1 -1
  229. package/dist/internal/components/DropdownMenu.js +1 -1
  230. package/dist/internal/components/FileUpload.js +1 -1
  231. package/dist/internal/components/FullScreenModal.js +1 -1
  232. package/dist/internal/components/HoverCard.js +1 -1
  233. package/dist/internal/components/InputGroup.js +1 -1
  234. package/dist/internal/components/Kbd.js +1 -1
  235. package/dist/internal/components/MarkedText.js +1 -1
  236. package/dist/internal/components/MergeEditor/ConflictStatus/ConflictStatusIndicator.js +1 -1
  237. package/dist/internal/components/Modal.js +1 -1
  238. package/dist/internal/components/Navbar.js +1 -1
  239. package/dist/internal/components/Pagination.js +1 -1
  240. package/dist/internal/components/PanelWithDetails.js +1 -1
  241. package/dist/internal/components/Popconfirm.js +1 -1
  242. package/dist/internal/components/Popover.js +1 -1
  243. package/dist/internal/components/RadioGroup.js +1 -1
  244. package/dist/internal/components/Search.js +1 -1
  245. package/dist/internal/components/Select.js +1 -1
  246. package/dist/internal/components/Separator.js.map +1 -1
  247. package/dist/internal/components/Sheet.js +1 -1
  248. package/dist/internal/components/Sidebar.js +1 -1
  249. package/dist/internal/components/Skeleton/Skeleton.js +5 -9
  250. package/dist/internal/components/Skeleton/Skeleton.js.map +1 -1
  251. package/dist/internal/components/Slider.js +1 -1
  252. package/dist/internal/components/SpotlightBackdrop.js +3 -8
  253. package/dist/internal/components/SpotlightBackdrop.js.map +1 -1
  254. package/dist/internal/components/StatusDot.js +8 -15
  255. package/dist/internal/components/StatusDot.js.map +1 -1
  256. package/dist/internal/components/Stepper.js +1 -1
  257. package/dist/internal/components/Switch.js +1 -1
  258. package/dist/internal/components/Table.js +1 -1
  259. package/dist/internal/components/Tabs.js +1 -1
  260. package/dist/internal/components/ThemeProvider.js +3 -3
  261. package/dist/internal/components/TimePicker.js +1 -1
  262. package/dist/internal/components/Timeline.js +1 -1
  263. package/dist/internal/components/Toast.js +2 -2
  264. package/dist/internal/components/Tooltip.js +1 -1
  265. package/dist/internal/components/Truncated.js +4 -8
  266. package/dist/internal/components/Truncated.js.map +1 -1
  267. package/dist/internal/components/Workbench.js +1 -1
  268. package/dist/internal/components/ZoomableSvg.js +1 -1
  269. package/dist/internal/hooks/useScrollbarPosition.js +1 -1
  270. package/dist/internal/hooks/useStableCallback.js +4 -13
  271. package/dist/internal/hooks/useStableCallback.js.map +1 -1
  272. package/dist/internal/utils.js +2 -2
  273. package/dist/markdown-editor.d.ts +15 -37
  274. package/dist/markdown-editor.js +17 -23
  275. package/dist/markdown-editor.js.map +1 -1
  276. package/dist/mermaid.d.ts +4 -6
  277. package/dist/mermaid.js +1 -1
  278. package/dist/rjsf.d.ts +9 -19
  279. package/dist/rjsf.js +44 -84
  280. package/dist/rjsf.js.map +1 -1
  281. package/dist/{styles-BAFscjSV.js → styles-gzcjOyKv.js} +6 -6
  282. package/dist/styles-gzcjOyKv.js.map +1 -0
  283. package/dist/styles.css +1 -1
  284. package/dist/svgTransforms-Dw2hRA-i.js +51 -0
  285. package/dist/svgTransforms-Dw2hRA-i.js.map +1 -0
  286. package/dist/testing.d.ts +3 -10
  287. package/dist/testing.js +5 -12
  288. package/dist/testing.js.map +1 -1
  289. package/dist/themeTokens-7DEab0kp.js +31 -0
  290. package/dist/themeTokens-7DEab0kp.js.map +1 -0
  291. package/dist/{toast-DIC0iNRf.js → toast-CyXEdaCZ.js} +3 -3
  292. package/dist/toast-CyXEdaCZ.js.map +1 -0
  293. package/dist/{themeScopeContext-D7fSyb06.js → useColorSchemeState-Cw4MCXUs.js} +14 -14
  294. package/dist/useColorSchemeState-Cw4MCXUs.js.map +1 -0
  295. package/dist/{useControllableState-M6494mCT.js → useControllableState-CUYXMsfz.js} +3 -7
  296. package/dist/useControllableState-CUYXMsfz.js.map +1 -0
  297. package/dist/useElement-D-RjrGa4.js +21 -0
  298. package/dist/useElement-D-RjrGa4.js.map +1 -0
  299. package/dist/useThemeAttributes-B199Regy.js +67 -0
  300. package/dist/useThemeAttributes-B199Regy.js.map +1 -0
  301. package/dist/{utils-BW4AE8VP.js → utils-Bd28bWgm.js} +31 -26
  302. package/dist/utils-Bd28bWgm.js.map +1 -0
  303. package/dist/vega.d.ts +8 -30
  304. package/dist/vega.js +5 -13
  305. package/dist/vega.js.map +1 -1
  306. package/dist/{vegaTheme-CSvFEMBl.js → vegaTheme-VQMWTlBw.js} +7 -21
  307. package/dist/vegaTheme-VQMWTlBw.js.map +1 -0
  308. package/package.json +10 -9
  309. package/src/styles.css +120 -14
  310. package/src/theme.css +126 -6
  311. package/dist/AIKit-ELIsegJz.js.map +0 -1
  312. package/dist/Alert-BsIM_oFK.js.map +0 -1
  313. package/dist/AlertModal-BGJdaRRj.js.map +0 -1
  314. package/dist/AppShell-DRgJxpXW.js.map +0 -1
  315. package/dist/Badge-o5jURtpB.js.map +0 -1
  316. package/dist/BrandLogo-CoKBk4MI.js.map +0 -1
  317. package/dist/Breadcrumb-xqEUxfwn.js.map +0 -1
  318. package/dist/Button-DsRrU5F1.js.map +0 -1
  319. package/dist/Calendar-cG5NIJ4O.js.map +0 -1
  320. package/dist/Card-Dyo7055Q.js.map +0 -1
  321. package/dist/Checkbox-Dq5fPNrO.js.map +0 -1
  322. package/dist/CodeEditor-BJKJXA0c.js.map +0 -1
  323. package/dist/ColorInput-Bj3dfPFA.js.map +0 -1
  324. package/dist/ColorModeSwitch-CWt-DZGC.js.map +0 -1
  325. package/dist/Combobox-D8PrEqTG.js +0 -619
  326. package/dist/Combobox-D8PrEqTG.js.map +0 -1
  327. package/dist/DateRangeInput-7M9Z4cVO.js.map +0 -1
  328. package/dist/DateRangePicker-DjSUFjh4.js.map +0 -1
  329. package/dist/DropdownMenu-CgVwhDvl.js.map +0 -1
  330. package/dist/FieldItem-DZGIdiXE.js.map +0 -1
  331. package/dist/FormGroup-DR_gZ25-.js.map +0 -1
  332. package/dist/FullScreenModal-CN9nAs72.js.map +0 -1
  333. package/dist/InputGroup-Do8K2hvD.js.map +0 -1
  334. package/dist/Kbd-LCFMumoq.js.map +0 -1
  335. package/dist/MermaidDiagram-ZG0iiDV_.js.map +0 -1
  336. package/dist/Modal-I3VWk2oo.js.map +0 -1
  337. package/dist/ModalTitle-CeLM_mX9.js.map +0 -1
  338. package/dist/PageHeader-Q3IpCnQd.js.map +0 -1
  339. package/dist/PageLayout-DSVM-ASz.js.map +0 -1
  340. package/dist/PageToolbar-BKVJiDAL.js.map +0 -1
  341. package/dist/Popover-BEbQrC_P.js.map +0 -1
  342. package/dist/SearchInput-92r2bkA7.js.map +0 -1
  343. package/dist/SectionNav-CNLJsiVG.js.map +0 -1
  344. package/dist/Sheet-OparjIi-.js.map +0 -1
  345. package/dist/Sidebar-CLEbBtNY.js.map +0 -1
  346. package/dist/TextInput-CFTf4Cz1.js.map +0 -1
  347. package/dist/ThemeProvider-DAmNn9Sd.js.map +0 -1
  348. package/dist/ZoomableSvg-BZlk3PFJ.js.map +0 -1
  349. package/dist/context-D7X470dy.js.map +0 -1
  350. package/dist/findLiteralMatches-BGBw8Vbl.js.map +0 -1
  351. package/dist/icons-Cek151jC.js.map +0 -1
  352. package/dist/styles-BAFscjSV.js.map +0 -1
  353. package/dist/svgTransforms-CJAYPk7o.js +0 -81
  354. package/dist/svgTransforms-CJAYPk7o.js.map +0 -1
  355. package/dist/themeScopeContext-D7fSyb06.js.map +0 -1
  356. package/dist/themeTokens-qP1-55O7.js +0 -119
  357. package/dist/themeTokens-qP1-55O7.js.map +0 -1
  358. package/dist/toast-DIC0iNRf.js.map +0 -1
  359. package/dist/useControllableState-M6494mCT.js.map +0 -1
  360. package/dist/useElement-BK3AAiIf.js +0 -24
  361. package/dist/useElement-BK3AAiIf.js.map +0 -1
  362. package/dist/utils-BW4AE8VP.js.map +0 -1
  363. package/dist/vegaTheme-CSvFEMBl.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DateInput-B6N8g0ra.js","names":["CalendarIcon"],"sources":["../src/blocks/DateInput/helpers.ts","../src/blocks/DateInput/DateInput.tsx"],"sourcesContent":["export const formatDate = (date: Date | null | undefined, inputValue: string): string => {\n if (!date) {\n return inputValue;\n }\n return date.toLocaleDateString();\n};\n\n// Detect locale day/month/year order once, matching toLocaleDateString() output\nconst datePartOrder = new Intl.DateTimeFormat()\n .formatToParts(new Date(2000, 0, 2))\n .filter(\n (p): p is { type: 'day' | 'month' | 'year'; value: string } =>\n p.type === 'day' || p.type === 'month' || p.type === 'year',\n )\n .map((p) => p.type);\n\nexport const parseDate = (value: string): Date | null => {\n if (!value.trim()) return null;\n\n // Try locale-aware parsing first (matches toLocaleDateString round-trip)\n const nums = value.match(/\\d+/g)?.map(Number);\n if (nums && nums.length >= 3) {\n const parts = Object.fromEntries(datePartOrder.map((type, i) => [type, nums[i]]));\n const year = parts.year;\n const month = parts.month;\n const day = parts.day;\n\n if (\n year != null &&\n month != null &&\n day != null &&\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= 31\n ) {\n const date = new Date(year, month - 1, day);\n if (date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day) {\n return date;\n }\n }\n }\n\n // Fallback: detect ISO YYYY-MM-DD and construct as local midnight to avoid UTC offset issues\n const isoMatch = value.match(/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/);\n if (isoMatch) {\n const y = Number(isoMatch[1]);\n const m = Number(isoMatch[2]) - 1;\n const d = Number(isoMatch[3]);\n const date = new Date(y, m, d);\n if (date.getFullYear() === y && date.getMonth() === m && date.getDate() === d) {\n return date;\n }\n return null;\n }\n\n const fallback = new Date(value);\n return isNaN(fallback.getTime()) ? null : fallback;\n};\n","import { useRef, useState } from 'react';\nimport type {\n ChangeEventHandler,\n ComponentProps,\n ComponentRef,\n FocusEventHandler,\n MouseEventHandler,\n} from 'react';\nimport type { Matcher } from 'react-day-picker';\n\nimport { DatePicker } from '../../components/DatePicker';\nimport { InputGroup } from '../../components/InputGroup';\nimport { useControllableState } from '../../hooks/useControllableState';\nimport { Calendar as CalendarIcon, X } from '../../icons';\nimport { createChangeInputEvent, mergeRefs } from '../../utils';\n\nimport { formatDate, parseDate } from './helpers';\n\ntype InputGroupProps = Pick<\n ComponentProps<typeof InputGroup>,\n 'variant' | 'focusVariant' | 'state' | 'sizing'\n>;\n\ntype InputGroupInputProps = Omit<\n ComponentProps<typeof InputGroup.Input>,\n 'value' | 'defaultValue' | 'type'\n>;\n\ntype Props = InputGroupProps &\n InputGroupInputProps & {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n onValueBlur?: (value: Date | null) => void;\n allowClear?: boolean;\n disabledDays?: Matcher | Matcher[];\n endMonth?: Date;\n startMonth?: Date;\n };\n\nexport const DateInput = ({\n ref,\n\n // group props\n state,\n variant,\n focusVariant,\n sizing,\n className,\n\n // own props\n value,\n defaultValue,\n onValueChange,\n onValueBlur,\n onChange,\n onBlur,\n onFocus,\n allowClear = false,\n disabledDays,\n endMonth,\n startMonth,\n\n // input props\n disabled,\n readOnly,\n placeholder = 'Select a date',\n ...restInputProps\n}: Props) => {\n const inputRef = useRef<ComponentRef<'input'>>(null);\n\n const [inputValue, setInputValue] = useState('');\n const [hasFocus, setHasFocus] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [month, setMonth] = useState<Date>(new Date());\n\n // `onValueChange` is fired explicitly per-path below (not through the hook), because commits\n // happen on blur / picker-select rather than on every keystroke.\n const [currentValue, setCurrentValue] = useControllableState<Date | null>({\n prop: value,\n defaultProp: defaultValue ?? null,\n });\n\n const canClear = allowClear && !!currentValue && !disabled && !readOnly;\n const showPicker = !disabled && !readOnly;\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n setInputValue(newValue);\n onChange?.(event);\n\n const parsedDate = parseDate(newValue);\n if (parsedDate !== null || !newValue.trim()) {\n onValueChange?.(parsedDate);\n }\n };\n\n const handleFocus: FocusEventHandler<HTMLInputElement> = (event) => {\n const formatted = formatDate(currentValue, '');\n setInputValue(formatted);\n setHasFocus(true);\n onFocus?.(event);\n };\n\n const handleBlur: FocusEventHandler<HTMLInputElement> = (event) => {\n setHasFocus(false);\n onBlur?.(event);\n\n // If the field still shows the formatted current value (focused and blurred\n // without editing), keep it as-is. `formatDate` uses `toLocaleDateString`,\n // whose output is not reliably parseable by `parseDate` in every locale, so\n // round-tripping an untouched value could wrongly null it.\n const text = event.target.value;\n const parsedDate = text === formatDate(currentValue, '') ? currentValue : parseDate(text);\n onValueBlur?.(parsedDate);\n\n setCurrentValue(parsedDate);\n };\n\n const handleDatePickerChange = (newValue?: Date) => {\n const dateValue = newValue ?? null;\n\n setCurrentValue(dateValue);\n onValueChange?.(dateValue);\n\n setHasFocus(false);\n setIsOpen(false);\n };\n\n const handleClear: MouseEventHandler<HTMLButtonElement> = () => {\n if (!inputRef.current) return;\n inputRef.current.value = '';\n setInputValue('');\n setCurrentValue(null);\n onValueChange?.(null);\n onChange?.(createChangeInputEvent(inputRef.current));\n };\n\n const handleOpenChange = (open: boolean) => {\n if (open) {\n setMonth(currentValue ?? new Date());\n }\n setIsOpen(open);\n };\n\n const displayValue = hasFocus ? inputValue : formatDate(currentValue, '');\n\n return (\n <InputGroup\n state={state}\n variant={variant}\n sizing={sizing}\n focusVariant={focusVariant}\n className={className}\n >\n <InputGroup.Input\n {...restInputProps}\n ref={mergeRefs(ref ?? null, inputRef)}\n type=\"text\"\n value={displayValue}\n placeholder={placeholder}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n disabled={disabled}\n readOnly={readOnly}\n />\n\n {(canClear || showPicker) && (\n <InputGroup.Addon align=\"inline-end\">\n {canClear && (\n <InputGroup.Button\n aria-label=\"Clear date\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleClear}\n >\n <X className=\"tw:size-4\" />\n </InputGroup.Button>\n )}\n {showPicker && (\n <DatePicker\n disabled={disabledDays}\n endMonth={endMonth}\n mode=\"single\"\n month={month}\n onMonthChange={setMonth}\n onOpenChange={handleOpenChange}\n onSelect={handleDatePickerChange}\n open={isOpen}\n selected={currentValue ?? undefined}\n startMonth={startMonth}\n >\n <InputGroup.Button aria-label=\"Select Date\">\n <CalendarIcon className=\"tw:size-4\" />\n </InputGroup.Button>\n </DatePicker>\n )}\n </InputGroup.Addon>\n )}\n </InputGroup>\n );\n};\n"],"mappings":";;;;;;;;;AAAA,MAAa,cAAc,MAA+B,eAA+B;CACvF,IAAI,CAAC,MACH,OAAO;CAET,OAAO,KAAK,mBAAmB;AACjC;AAGA,MAAM,gBAAgB,IAAI,KAAK,eAAe,CAAC,CAC5C,cAAc,IAAI,KAAK,KAAM,GAAG,CAAC,CAAC,CAAC,CACnC,QACE,MACC,EAAE,SAAS,SAAS,EAAE,SAAS,WAAW,EAAE,SAAS,MACzD,CAAC,CACA,KAAK,MAAM,EAAE,IAAI;AAEpB,MAAa,aAAa,UAA+B;CACvD,IAAI,CAAC,MAAM,KAAK,GAAG,OAAO;CAG1B,MAAM,OAAO,MAAM,MAAM,MAAM,CAAC,EAAE,IAAI,MAAM;CAC5C,IAAI,QAAQ,KAAK,UAAU,GAAG;EAC5B,MAAM,QAA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Z;GACE,GAAI;GACJ,KAAK,UAAU,OAAO,MAAM,QAAQ;GACpC,MAAK;GACL,OAAO;GACM;GACb,UAAU;GACV,SAAS;GACT,QAAQ;GACE;GACA;EACX,CAAA,IAEC,YAAY,eACZ,qBAAC,WAAW,OAAZ;GAAkB,OAAM;GAAxB,UAAA,CACG,YACC,oBAAC,WAAW,QAAZ;IACE,cAAW;IACX,cAAc,UAAU,MAAM,eAAe;IAC7C,SAAS;IAET,UAAA,oBAAC,GAAD,EAAG,WAAU,YAAa,CAAA;GACT,CAAA,GAEpB,cACC,oBAAC,YAAD;IACE,UAAU;IACA;IACV,MAAK;IACE;IACP,eAAe;IACf,cAAc;IACd,UAAU;IACV,MAAM;IACN,UAAU,gBAAgB,KAAA;IACd;IAEZ,UAAA,oBAAC,WAAW,QAAZ;KAAmB,cAAW;KAC5B,UAAA,oBAACA,UAAD,EAAc,WAAU,YAAa,CAAA;IACpB,CAAA;GACT,CAAA,CAEE;EAEV,CAAA,CAAA;;AAEhB"}
1
+ {"version":3,"file":"DateInput-DyEErfJf.js","names":["CalendarIcon"],"sources":["../src/blocks/DateInput/helpers.ts","../src/blocks/DateInput/DateInput.tsx"],"sourcesContent":["export const formatDate = (date: Date | null | undefined, inputValue: string): string => {\n if (!date) {\n return inputValue;\n }\n return date.toLocaleDateString();\n};\n\n// Detect locale day/month/year order once, matching toLocaleDateString() output\nconst datePartOrder = new Intl.DateTimeFormat()\n .formatToParts(new Date(2000, 0, 2))\n .filter(\n (p): p is { type: 'day' | 'month' | 'year'; value: string } =>\n p.type === 'day' || p.type === 'month' || p.type === 'year',\n )\n .map((p) => p.type);\n\nexport const parseDate = (value: string): Date | null => {\n if (!value.trim()) return null;\n\n // Try locale-aware parsing first (matches toLocaleDateString round-trip)\n const nums = value.match(/\\d+/g)?.map(Number);\n if (nums && nums.length >= 3) {\n const parts = Object.fromEntries(datePartOrder.map((type, i) => [type, nums[i]]));\n const year = parts.year;\n const month = parts.month;\n const day = parts.day;\n\n if (\n year != null &&\n month != null &&\n day != null &&\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= 31\n ) {\n const date = new Date(year, month - 1, day);\n if (date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day) {\n return date;\n }\n }\n }\n\n // Fallback: detect ISO YYYY-MM-DD and construct as local midnight to avoid UTC offset issues\n const isoMatch = value.match(/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/);\n if (isoMatch) {\n const y = Number(isoMatch[1]);\n const m = Number(isoMatch[2]) - 1;\n const d = Number(isoMatch[3]);\n const date = new Date(y, m, d);\n if (date.getFullYear() === y && date.getMonth() === m && date.getDate() === d) {\n return date;\n }\n return null;\n }\n\n const fallback = new Date(value);\n return isNaN(fallback.getTime()) ? null : fallback;\n};\n","import { useRef, useState } from 'react';\nimport type {\n ChangeEventHandler,\n ComponentProps,\n ComponentRef,\n FocusEventHandler,\n MouseEventHandler,\n} from 'react';\nimport type { Matcher } from 'react-day-picker';\n\nimport { DatePicker } from '../../components/DatePicker';\nimport { InputGroup } from '../../components/InputGroup';\nimport { useControllableState } from '../../hooks/useControllableState';\nimport { Calendar as CalendarIcon, X } from '../../icons';\nimport { createChangeInputEvent, mergeRefs } from '../../utils';\n\nimport { formatDate, parseDate } from './helpers';\n\ntype InputGroupProps = Pick<\n ComponentProps<typeof InputGroup>,\n 'variant' | 'focusVariant' | 'state' | 'sizing'\n>;\n\ntype InputGroupInputProps = Omit<\n ComponentProps<typeof InputGroup.Input>,\n 'value' | 'defaultValue' | 'type'\n>;\n\ntype Props = InputGroupProps &\n InputGroupInputProps & {\n value?: Date | null;\n defaultValue?: Date | null;\n onValueChange?: (value: Date | null) => void;\n onValueBlur?: (value: Date | null) => void;\n allowClear?: boolean;\n disabledDays?: Matcher | Matcher[];\n endMonth?: Date;\n startMonth?: Date;\n };\n\nexport const DateInput = ({\n ref,\n\n // group props\n state,\n variant,\n focusVariant,\n sizing,\n className,\n\n // own props\n value,\n defaultValue,\n onValueChange,\n onValueBlur,\n onChange,\n onBlur,\n onFocus,\n allowClear = false,\n disabledDays,\n endMonth,\n startMonth,\n\n // input props\n disabled,\n readOnly,\n placeholder = 'Select a date',\n ...restInputProps\n}: Props) => {\n const inputRef = useRef<ComponentRef<'input'>>(null);\n\n const [inputValue, setInputValue] = useState('');\n const [hasFocus, setHasFocus] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [month, setMonth] = useState<Date>(new Date());\n\n // `onValueChange` is fired explicitly per-path below (not through the hook), because commits\n // happen on blur / picker-select rather than on every keystroke.\n const [currentValue, setCurrentValue] = useControllableState<Date | null>({\n prop: value,\n defaultProp: defaultValue ?? null,\n });\n\n const canClear = allowClear && !!currentValue && !disabled && !readOnly;\n const showPicker = !disabled && !readOnly;\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n setInputValue(newValue);\n onChange?.(event);\n\n const parsedDate = parseDate(newValue);\n if (parsedDate !== null || !newValue.trim()) {\n onValueChange?.(parsedDate);\n }\n };\n\n const handleFocus: FocusEventHandler<HTMLInputElement> = (event) => {\n const formatted = formatDate(currentValue, '');\n setInputValue(formatted);\n setHasFocus(true);\n onFocus?.(event);\n };\n\n const handleBlur: FocusEventHandler<HTMLInputElement> = (event) => {\n setHasFocus(false);\n onBlur?.(event);\n\n // If the field still shows the formatted current value (focused and blurred\n // without editing), keep it as-is. `formatDate` uses `toLocaleDateString`,\n // whose output is not reliably parseable by `parseDate` in every locale, so\n // round-tripping an untouched value could wrongly null it.\n const text = event.target.value;\n const parsedDate = text === formatDate(currentValue, '') ? currentValue : parseDate(text);\n onValueBlur?.(parsedDate);\n\n setCurrentValue(parsedDate);\n };\n\n const handleDatePickerChange = (newValue?: Date) => {\n const dateValue = newValue ?? null;\n\n setCurrentValue(dateValue);\n onValueChange?.(dateValue);\n\n setHasFocus(false);\n setIsOpen(false);\n };\n\n const handleClear: MouseEventHandler<HTMLButtonElement> = () => {\n if (!inputRef.current) return;\n inputRef.current.value = '';\n setInputValue('');\n setCurrentValue(null);\n onValueChange?.(null);\n onChange?.(createChangeInputEvent(inputRef.current));\n };\n\n const handleOpenChange = (open: boolean) => {\n if (open) {\n setMonth(currentValue ?? new Date());\n }\n setIsOpen(open);\n };\n\n const displayValue = hasFocus ? inputValue : formatDate(currentValue, '');\n\n return (\n <InputGroup\n state={state}\n variant={variant}\n sizing={sizing}\n focusVariant={focusVariant}\n className={className}\n >\n <InputGroup.Input\n {...restInputProps}\n ref={mergeRefs(ref ?? null, inputRef)}\n type=\"text\"\n value={displayValue}\n placeholder={placeholder}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n disabled={disabled}\n readOnly={readOnly}\n />\n\n {(canClear || showPicker) && (\n <InputGroup.Addon align=\"inline-end\">\n {canClear && (\n <InputGroup.Button\n aria-label=\"Clear date\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleClear}\n >\n <X className=\"tw:size-4\" />\n </InputGroup.Button>\n )}\n {showPicker && (\n <DatePicker\n disabled={disabledDays}\n endMonth={endMonth}\n mode=\"single\"\n month={month}\n onMonthChange={setMonth}\n onOpenChange={handleOpenChange}\n onSelect={handleDatePickerChange}\n open={isOpen}\n selected={currentValue ?? undefined}\n startMonth={startMonth}\n >\n <InputGroup.Button aria-label=\"Select Date\">\n <CalendarIcon className=\"tw:size-4\" />\n </InputGroup.Button>\n </DatePicker>\n )}\n </InputGroup.Addon>\n )}\n </InputGroup>\n );\n};\n"],"mappings":";;;;;;;;;AAAA,MAAa,cAAc,MAA+B,eAA+B;CACvF,IAAI,CAAC,MACH,OAAO;CAET,OAAO,KAAK,mBAAmB;AACjC;AAGA,MAAM,gBAAgB,IAAI,KAAK,eAAe,CAAC,CAC5C,cAAc,IAAI,KAAK,KAAM,GAAG,CAAC,CAAC,CAAC,CACnC,QACE,MACC,EAAE,SAAS,SAAS,EAAE,SAAS,WAAW,EAAE,SAAS,MACzD,CAAC,CACA,KAAK,MAAM,EAAE,IAAI;AAEpB,MA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gB,IAAI,KAAK,CAAC;EAErC,UAAU,IAAI;CAChB;CAEA,MAAM,eAAe,WAAW,aAAa,WAAW,cAAc,EAAE;CAExE,OACE,qBAAC,YAAD;EACS;EACE;EACD;EACM;EACH;EALb,UAAA,CAOE,oBAAC,WAAW,OAAZ;GACE,GAAI;GACJ,KAAK,UAAU,OAAO,MAAM,QAAQ;GACpC,MAAK;GACL,OAAO;GACM;GACb,UAAU;GACV,SAAS;GACT,QAAQ;GACE;GACA;EACX,CAAA,IAEC,YAAY,eACZ,qBAAC,WAAW,OAAZ;GAAkB,OAAM;GAAxB,UAAA,CACG,YACC,oBAAC,WAAW,QAAZ;IACE,cAAW;IACX,cAAc,UAAU,MAAM,eAAe;IAC7C,SAAS;IAET,UAAA,oBAAC,GAAD,EAAG,WAAU,YAAa,CAAA;GACT,CAAA,GAEpB,cACC,oBAAC,YAAD;IACE,UAAU;IACA;IACV,MAAK;IACE;IACP,eAAe;IACf,cAAc;IACd,UAAU;IACV,MAAM;IACN,UAAU,gBAAgB,KAAA;IACd;IAEZ,UAAA,oBAAC,WAAW,QAAZ;KAAmB,cAAW;KAC5B,UAAA,oBAACA,UAAD,EAAc,WAAU,YAAa,CAAA;IACpB,CAAA;GACT,CAAA,CAEE;EAEV,CAAA,CAAA;;AAEhB"}
@@ -1,5 +1,5 @@
1
- import { Popover } from "./Popover-BEbQrC_P.js";
2
- import { Calendar } from "./Calendar-cG5NIJ4O.js";
1
+ import { Popover } from "./Popover-CEk915I1.js";
2
+ import { Calendar } from "./Calendar-DFtmZzbF.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
  //#region src/components/DatePicker/DatePicker.tsx
5
5
  const DatePicker = ({ align = "end", alignOffset = -18, children, defaultOpen, onOpenChange, open, sideOffset = 12, ...calendarProps }) => /* @__PURE__ */ jsxs(Popover, {
@@ -21,4 +21,4 @@ DatePicker.displayName = "DatePicker";
21
21
  //#endregion
22
22
  export { DatePicker };
23
23
 
24
- //# sourceMappingURL=DatePicker-nA8YdE84.js.map
24
+ //# sourceMappingURL=DatePicker-CtSa9b3V.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker-nA8YdE84.js","names":[],"sources":["../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport type { PopoverContentProps, PopoverProps } from '@radix-ui/react-popover';\n\nimport type { CalendarProps } from '../Calendar';\nimport { Calendar } from '../Calendar';\nimport { Popover } from '../Popover';\n\ntype OwnPopoverProps = PropsWithChildren &\n Pick<PopoverProps, 'open' | 'onOpenChange' | 'defaultOpen'> &\n Pick<PopoverContentProps, 'align' | 'alignOffset' | 'sideOffset'>;\n\ntype DatePickerProps = OwnPopoverProps & CalendarProps;\n\nexport const DatePicker = ({\n align = 'end',\n alignOffset = -18,\n children,\n defaultOpen,\n onOpenChange,\n open,\n sideOffset = 12,\n ...calendarProps\n}: DatePickerProps) => (\n <Popover defaultOpen={defaultOpen} open={open} onOpenChange={onOpenChange}>\n <Popover.Trigger asChild>{children}</Popover.Trigger>\n <Popover.Content\n align={align}\n alignOffset={alignOffset}\n className=\"tw:w-auto tw:p-0\"\n sideOffset={sideOffset}\n >\n <Calendar {...calendarProps} />\n </Popover.Content>\n </Popover>\n);\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";;;;AAaA,MAAa,cAAc,EACzB,QAAQ,OACR,cAAc,KACd,UACA,aACA,cACA,MACA,aAAa,IACb,GAAG,oBAEH,qBAAC,SAAD;CAAsB;CAAmB;CAAoB;CAA7D,UAAA,CACE,oBAAC,QAAQ,SAAT;EAAiB,SAAA;EAAS;CAA0B,CAAA,GACpD,oBAAC,QAAQ,SAAT;EACS;EACM;EACb,WAAU;EACE;EAEZ,UAAA,oBAAC,UAAD,EAAU,GAAI,cAAgB,CAAA;CACf,CAAA,CACV;;AAGX,WAAW,cAAc"}
1
+ {"version":3,"file":"DatePicker-CtSa9b3V.js","names":[],"sources":["../src/components/DatePicker/DatePicker.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport type { PopoverContentProps, PopoverProps } from '@radix-ui/react-popover';\n\nimport type { CalendarProps } from '../Calendar';\nimport { Calendar } from '../Calendar';\nimport { Popover } from '../Popover';\n\ntype OwnPopoverProps = PropsWithChildren &\n Pick<PopoverProps, 'open' | 'onOpenChange' | 'defaultOpen'> &\n Pick<PopoverContentProps, 'align' | 'alignOffset' | 'sideOffset'>;\n\ntype DatePickerProps = OwnPopoverProps & CalendarProps;\n\nexport const DatePicker = ({\n align = 'end',\n alignOffset = -18,\n children,\n defaultOpen,\n onOpenChange,\n open,\n sideOffset = 12,\n ...calendarProps\n}: DatePickerProps) => (\n <Popover defaultOpen={defaultOpen} open={open} onOpenChange={onOpenChange}>\n <Popover.Trigger asChild>{children}</Popover.Trigger>\n <Popover.Content\n align={align}\n alignOffset={alignOffset}\n className=\"tw:w-auto tw:p-0\"\n sideOffset={sideOffset}\n >\n <Calendar {...calendarProps} />\n </Popover.Content>\n </Popover>\n);\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";;;;AAaA,MAAa,cAAc,EACzB,QAAQ,OACR,cAAc,KACd,UACA,aACA,cACA,MACA,aAAa,IACb,GAAG,oBAEH,qBAAC,SAAD;CAAsB;CAAmB;CAAoB;CAA7D,UAAA,CACE,oBAAC,QAAQ,SAAT;EAAiB,SAAA;EAAS;CAA0B,CAAA,GACpD,oBAAC,QAAQ,SAAT;EACS;EACM;EACb,WAAU;EACE;EAEZ,UAAA,oBAAC,UAAD,EAAU,GAAI,cAAgB,CAAA;CACf,CAAA,CACV;;AAGX,WAAW,cAAc"}
@@ -1,9 +1,9 @@
1
- import { createChangeInputEvent } from "./utils-BW4AE8VP.js";
1
+ import { createChangeInputEvent } from "./utils-Bd28bWgm.js";
2
2
  import { mergeRefs } from "./internal/utils/mergeRefs.js";
3
- import { Calendar, X } from "./icons-Cek151jC.js";
4
- import { InputGroup } from "./InputGroup-Do8K2hvD.js";
5
- import { useControllableState } from "./useControllableState-M6494mCT.js";
6
- import { DatePicker } from "./DatePicker-nA8YdE84.js";
3
+ import { Calendar, X } from "./icons-wcA70iQx.js";
4
+ import { InputGroup } from "./InputGroup-B4QOPxHl.js";
5
+ import { useControllableState } from "./useControllableState-CUYXMsfz.js";
6
+ import { DatePicker } from "./DatePicker-CtSa9b3V.js";
7
7
  import { useRef, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  //#region src/blocks/DateRangeInput/helpers.ts
@@ -14,15 +14,11 @@ const formatDateRange = (range, inputValue) => {
14
14
  };
15
15
  const ISO_DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
16
16
  /**
17
- * `new Date('2024-01-15')` is spec'd as UTC midnight, so reading it back with the
18
- * local getters this component relies on (`getDate`, `toLocaleDateString`) yields
19
- * the previous day for users west of UTC. Appending a time makes the ISO form
20
- * parse as local time instead, while keeping `new Date`'s validation — an
21
- * out-of-range month or day is still `Invalid Date`, whereas building the parts
22
- * via `new Date(y, m - 1, d)` would silently roll '2024-13-45' over to 2025-02-14.
17
+ * Parses date-only ISO (`2024-01-15`) as local time, not UTC midnight.
23
18
  *
24
- * Every other format accepted here ('01/15/2024', 'Jan 15, 2024', '2024/01/15')
25
- * is already parsed as local time, so only the date-only ISO form is rewritten.
19
+ * - UTC midnight reads back as the previous day west of UTC.
20
+ * - Keeps `new Date` validation; `new Date(y, m - 1, d)` would roll `2024-13-45` over.
21
+ * - Other accepted formats already parse as local time.
26
22
  */
27
23
  const parseLocalDate = (value) => ISO_DATE_ONLY.test(value) ? /* @__PURE__ */ new Date(`${value}T00:00:00`) : new Date(value);
28
24
  const parseDateRange = (value) => {
@@ -136,4 +132,4 @@ const DateRangeInput = ({ ref, state, variant, focusVariant, sizing, className,
136
132
  //#endregion
137
133
  export { DateRangeInput };
138
134
 
139
- //# sourceMappingURL=DateRangeInput-7M9Z4cVO.js.map
135
+ //# sourceMappingURL=DateRangeInput-Dg7-VUd9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangeInput-Dg7-VUd9.js","names":["CalendarIcon"],"sources":["../src/blocks/DateRangeInput/helpers.ts","../src/blocks/DateRangeInput/DateRangeInput.tsx"],"sourcesContent":["import type { DateRange } from 'react-day-picker';\n\nexport const formatDateRange = (\n range: DateRange | null | undefined,\n inputValue: string,\n): string => {\n if (!range) {\n return inputValue;\n }\n\n const { from, to } = range;\n const fromStr = from?.toLocaleDateString();\n const toStr = to?.toLocaleDateString();\n return `${fromStr} - ${toStr}`;\n};\n\nconst ISO_DATE_ONLY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/**\n * Parses date-only ISO (`2024-01-15`) as local time, not UTC midnight.\n *\n * - UTC midnight reads back as the previous day west of UTC.\n * - Keeps `new Date` validation; `new Date(y, m - 1, d)` would roll `2024-13-45` over.\n * - Other accepted formats already parse as local time.\n */\nconst parseLocalDate = (value: string): Date =>\n ISO_DATE_ONLY.test(value) ? new Date(`${value}T00:00:00`) : new Date(value);\n\nexport const parseDateRange = (value: string): DateRange | null => {\n const parts = value.split(' - ');\n if (parts.length !== 2) {\n return null;\n }\n\n const [fromPart, toPart] = parts;\n if (!fromPart || !toPart) {\n return null;\n }\n\n const from = parseLocalDate(fromPart.trim());\n const to = parseLocalDate(toPart.trim());\n\n if (isNaN(from.getTime()) || isNaN(to.getTime())) {\n return null;\n }\n\n return { from, to };\n};\n","import { useRef, useState } from 'react';\nimport type { ChangeEventHandler, ComponentProps, ComponentRef, FocusEventHandler } from 'react';\nimport type { DateRange } from 'react-day-picker';\n\nimport { DatePicker } from '../../components/DatePicker';\nimport { InputGroup } from '../../components/InputGroup';\nimport { useControllableState } from '../../hooks/useControllableState';\nimport { Calendar as CalendarIcon, X } from '../../icons';\nimport { createChangeInputEvent, mergeRefs } from '../../utils';\n\nimport { formatDateRange, parseDateRange } from './helpers';\n\ntype InputGroupProps = Pick<\n ComponentProps<typeof InputGroup>,\n 'variant' | 'focusVariant' | 'state' | 'sizing'\n>;\n\ntype InputGroupInputProps = Omit<\n ComponentProps<typeof InputGroup.Input>,\n 'value' | 'defaultValue' | 'type'\n>;\n\ntype Props = InputGroupProps &\n InputGroupInputProps & {\n value?: DateRange | null;\n defaultValue?: DateRange | null;\n onValueChange?: (value: DateRange | null) => void;\n onValueBlur?: (value: DateRange | null) => void;\n allowClear?: boolean;\n startMonth?: Date;\n endMonth?: Date;\n };\n\nexport const DateRangeInput = ({\n ref,\n\n // group props\n state,\n variant,\n focusVariant,\n sizing,\n className,\n\n // own props\n value: valueProp,\n defaultValue,\n onValueChange,\n onValueBlur,\n onChange,\n onBlur,\n onFocus,\n allowClear = false,\n startMonth,\n endMonth,\n\n // input props\n disabled,\n readOnly,\n placeholder = 'Select a date range',\n ...restInputProps\n}: Props) => {\n const inputRef = useRef<ComponentRef<'input'>>(null);\n\n const [inputValue, setInputValue] = useState('');\n const [hasFocus, setHasFocus] = useState(false);\n const [isOpen, setIsOpen] = useState(false);\n const [month, setMonth] = useState<Date>(new Date());\n\n // `onValueChange` is fired explicitly per-path below (not through the hook), because commits\n // happen on blur / picker-select rather than on every keystroke.\n const [currentValue, setCurrentValue] = useControllableState<DateRange | null>({\n prop: valueProp,\n defaultProp: defaultValue ?? null,\n });\n\n const canClear = allowClear && !!currentValue && !disabled && !readOnly;\n const showPicker = !disabled && !readOnly;\n\n const handleChange: ChangeEventHandler<HTMLInputElement> = (event) => {\n const newValue = event.target.value;\n setInputValue(newValue);\n onChange?.(event);\n\n const parsedRange = parseDateRange(newValue);\n if (parsedRange !== null || !newValue.trim()) {\n onValueChange?.(parsedRange);\n }\n };\n\n const handleFocus: FocusEventHandler<HTMLInputElement> = (event) => {\n setInputValue(formatDateRange(currentValue, ''));\n setHasFocus(true);\n onFocus?.(event);\n };\n\n const handleBlur: FocusEventHandler<HTMLInputElement> = (event) => {\n setHasFocus(false);\n onBlur?.(event);\n\n // If the field still shows the formatted current value (focused and blurred\n // without editing), keep it as-is. `formatDateRange` uses `toLocaleDateString`,\n // whose output is not reliably parseable by `new Date(...)` in every locale, so\n // round-tripping an untouched value through `parseDateRange` could wrongly null it.\n const text = event.target.value;\n const parsedRange =\n text === formatDateRange(currentValue, '') ? currentValue : parseDateRange(text);\n onValueBlur?.(parsedRange);\n\n setCurrentValue(parsedRange);\n };\n\n const handleDatePickerChange = (newValue: DateRange | undefined) => {\n const rangeValue = newValue ?? null;\n\n setCurrentValue(rangeValue);\n onValueChange?.(rangeValue);\n\n setHasFocus(false);\n };\n\n const handleClear = () => {\n if (!inputRef.current) return;\n inputRef.current.value = '';\n setInputValue('');\n setCurrentValue(null);\n onValueChange?.(null);\n onChange?.(createChangeInputEvent(inputRef.current));\n };\n\n const handleOpenChange = (open: boolean) => {\n if (open) {\n setMonth(currentValue?.from ?? new Date());\n }\n setIsOpen(open);\n };\n\n const displayValue = hasFocus ? inputValue : formatDateRange(currentValue, '');\n\n return (\n <InputGroup\n state={state}\n variant={variant}\n sizing={sizing}\n focusVariant={focusVariant}\n className={className}\n >\n <InputGroup.Input\n {...restInputProps}\n ref={mergeRefs(ref ?? null, inputRef)}\n type=\"text\"\n value={displayValue}\n placeholder={placeholder}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n disabled={disabled}\n readOnly={readOnly}\n />\n\n {(canClear || showPicker) && (\n <InputGroup.Addon align=\"inline-end\">\n {canClear && (\n <InputGroup.Button\n aria-label=\"Clear date range\"\n onMouseDown={(event) => event.preventDefault()}\n onClick={handleClear}\n >\n <X className=\"tw:size-4\" />\n </InputGroup.Button>\n )}\n {showPicker && (\n <DatePicker\n endMonth={endMonth}\n mode=\"range\"\n month={month}\n onMonthChange={setMonth}\n onOpenChange={handleOpenChange}\n onSelect={handleDatePickerChange}\n open={isOpen}\n startMonth={startMonth}\n selected={currentValue ?? undefined}\n >\n <InputGroup.Button aria-label=\"Select date range\">\n <CalendarIcon className=\"tw:size-4\" />\n </InputGroup.Button>\n </DatePicker>\n )}\n </InputGroup.Addon>\n )}\n </InputGroup>\n );\n};\n"],"mappings":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,WAAW,OAAZ;GAAkB,OAAM;GAAxB,UAAA,CACG,YACC,oBAAC,WAAW,QAAZ;IACE,cAAW;IACX,cAAc,UAAU,MAAM,eAAe;IAC7C,SAAS;IAET,UAAA,oBAAC,GAAD,EAAG,WAAU,YAAa,CAAA;GACT,CAAA,GAEpB,cACC,oBAAC,YAAD;IACY;IACV,MAAK;IACE;IACP,eAAe;IACf,cAAc;IACd,UAAU;IACV,MAAM;IACM;IACZ,UAAU,gBAAgB,KAAA;IAE1B,UAAA,oBAAC,WAAW,QAAZ;KAAmB,cAAW;KAC5B,UAAA,oBAACA,UAAD,EAAc,WAAU,YAAa,CAAA;IACpB,CAAA;GACT,CAAA,CAEE;EAEV,CAAA,CAAA;;AAEhB"}
@@ -1,11 +1,11 @@
1
1
  import { cn } from "./classNames-BzrkDnOD.js";
2
- import { useArgoDesign } from "./context-D7X470dy.js";
3
- import { ChevronDown } from "./icons-Cek151jC.js";
4
- import { Button } from "./Button-DsRrU5F1.js";
5
- import { Popover } from "./Popover-BEbQrC_P.js";
6
- import { Calendar } from "./Calendar-cG5NIJ4O.js";
7
- import { overlayTriggerVariants } from "./styles-BAFscjSV.js";
8
- import { TimePicker, formatTime, pad, parseTime } from "./TimePicker-BGeqc-Ed.js";
2
+ import { useArgoDesign } from "./context-U293r3v-.js";
3
+ import { ChevronDown } from "./icons-wcA70iQx.js";
4
+ import { Button } from "./Button-Ca4Q3VJU.js";
5
+ import { Popover } from "./Popover-CEk915I1.js";
6
+ import { Calendar } from "./Calendar-DFtmZzbF.js";
7
+ import { overlayTriggerVariants } from "./styles-gzcjOyKv.js";
8
+ import { TimePicker, formatTime, pad, parseTime } from "./TimePicker-CDGYrRxi.js";
9
9
  import { useState } from "react";
10
10
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
11
11
  //#region src/components/DateRangePicker/DateRangePicker.tsx
@@ -44,11 +44,7 @@ const TimeField = ({ label, date, onChange }) => /* @__PURE__ */ jsxs("div", {
44
44
  })
45
45
  })]
46
46
  });
47
- /**
48
- * Range-mode date picker — `Popover` + `Calendar` in range mode, with an optional preset sidebar,
49
- * a time-of-day row (`withTime`) and an explicit Apply step (`requireApply`). Use for selecting a
50
- * `{ from, to }` pair; for a single date use `DatePicker`.
51
- */
47
+ /** Picks a `{ from, to }` range, with optional presets, time row and Apply step; single date: `DatePicker`. */
52
48
  const DateRangePicker = ({ align = "start", alignOffset, className, defaultOpen, disabled = false, disabledDays, formatDate, label, onChange, onOpenChange, onPresetSelect, open, placeholder = "Pick a date range", presets, requireApply = false, sideOffset, value, variant, withTime = false }) => {
53
49
  const isArgoDesign = useArgoDesign();
54
50
  const [draft, setDraft] = useState(value);
@@ -156,4 +152,4 @@ DateRangePicker.displayName = "DateRangePicker";
156
152
  //#endregion
157
153
  export { DateRangePicker };
158
154
 
159
- //# sourceMappingURL=DateRangePicker-DjSUFjh4.js.map
155
+ //# sourceMappingURL=DateRangePicker-BoPnh4aH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateRangePicker-BoPnh4aH.js","names":[],"sources":["../src/components/DateRangePicker/DateRangePicker.tsx"],"sourcesContent":["import { useState } from 'react';\nimport type { ReactNode } from 'react';\nimport type { DateRange as DayPickerDateRange, Matcher } from 'react-day-picker';\nimport type { PopoverContentProps, PopoverProps } from '@radix-ui/react-popover';\nimport type { VariantProps } from 'class-variance-authority';\n\nimport { ChevronDown } from '../../icons';\nimport { cn } from '../../utils';\nimport { Button } from '../Button';\nimport { Calendar } from '../Calendar';\nimport { overlayTriggerVariants } from '../OverlayTrigger/styles';\nimport { Popover } from '../Popover';\nimport { useArgoDesign } from '../ThemeProvider/context';\nimport { TimePicker } from '../TimePicker';\nimport { formatTime, pad, parseTime } from '../TimePicker/utils';\n\nexport type DateRange = {\n from: Date;\n to?: Date;\n};\n\nexport type DateRangePreset = {\n label: string;\n /** Omit for a `value` preset, or for a clear preset (\"All time\") that calls `onChange(undefined)`. */\n range?: DateRange;\n /** Echoed through `onPresetSelect` instead of `range` — e.g. a server-resolved token like `-7 days`. */\n value?: string;\n};\n\ntype DateRangePickerProps = {\n value: DateRange | undefined;\n onChange: (range: DateRange | undefined) => void;\n /** Replaces the trigger's whole range text, e.g. the active preset name; to restyle dates use `formatDate`. */\n label?: ReactNode;\n /** Formats each end of the range on the trigger in place of ISO; the from → to join stays. */\n formatDate?: (date: Date) => string;\n placeholder?: string;\n presets?: readonly DateRangePreset[];\n /** Called instead of `onChange` when a preset is picked, with the preset itself. */\n onPresetSelect?: (preset: DateRangePreset) => void;\n /** Adds a start/end time-of-day row; the emitted `from` / `to` then carry hours and minutes. */\n withTime?: boolean;\n /** Hold edits in a draft and emit only on Apply, so one range costs one `onChange`. */\n requireApply?: boolean;\n /** Days that cannot be picked, as a react-day-picker matcher — e.g. `{ after: new Date() }`. */\n disabledDays?: Matcher | Matcher[];\n variant?: Exclude<VariantProps<typeof overlayTriggerVariants>['variant'], 'argo'>;\n disabled?: boolean;\n className?: string;\n} & Pick<PopoverProps, 'open' | 'onOpenChange' | 'defaultOpen'> &\n Pick<PopoverContentProps, 'align' | 'alignOffset' | 'sideOffset'>;\n\nconst timeOf = (date: Date) => formatTime(date.getHours(), date.getMinutes());\n\nconst isoDate = (date: Date) =>\n `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;\n\nconst formatRange = (\n range: DateRange | undefined,\n format: (date: Date) => string,\n): string | null => {\n if (!range?.from) return null;\n return range.to ? `${format(range.from)} → ${format(range.to)}` : format(range.from);\n};\n\nconst withHoursMinutes = (target: Date, hour: number, minute: number) => {\n const next = new Date(target);\n next.setHours(hour, minute, 0, 0);\n return next;\n};\n\nconst withTimeOf = (target: Date, source: Date) =>\n withHoursMinutes(target, source.getHours(), source.getMinutes());\n\n/** Returns `target` at `time` (\"HH:mm\"); unparseable input leaves it alone. */\nconst atTime = (target: Date, time: string) => {\n const { hour, minute } = parseTime(time);\n return hour === null || minute === null ? target : withHoursMinutes(target, hour, minute);\n};\n\ntype TimeFieldProps = {\n label: string;\n date: Date | undefined;\n onChange: (time: string) => void;\n};\n\n/** Time-of-day for one end of the range, on the same `TimePicker` the rest of the app uses. */\nconst TimeField = ({ label, date, onChange }: TimeFieldProps) => (\n <div className=\"tw:flex tw:items-center tw:gap-2 tw:text-sm\">\n <span className=\"tw:text-muted-foreground\">{label}</span>\n <TimePicker selected={date ? timeOf(date) : null} onSelect={onChange}>\n <Button variant=\"outline\" size=\"small\" disabled={!date} aria-label={`${label} time`}>\n {date ? timeOf(date) : '--:--'}\n </Button>\n </TimePicker>\n </div>\n);\n\n/** Picks a `{ from, to }` range, with optional presets, time row and Apply step; single date: `DatePicker`. */\nexport const DateRangePicker = ({\n align = 'start',\n alignOffset,\n className,\n defaultOpen,\n disabled = false,\n disabledDays,\n formatDate,\n label,\n onChange,\n onOpenChange,\n onPresetSelect,\n open,\n placeholder = 'Pick a date range',\n presets,\n requireApply = false,\n sideOffset,\n value,\n variant,\n withTime = false,\n}: DateRangePickerProps) => {\n const isArgoDesign = useArgoDesign();\n const [draft, setDraft] = useState<DateRange | undefined>(value);\n\n const handleOpenChange = (nextOpen: boolean) => {\n // Reopening discards a cancelled draft.\n if (nextOpen) setDraft(value);\n onOpenChange?.(nextOpen);\n };\n\n const current = requireApply ? draft : value;\n\n const edit = (range: DateRange | undefined) => {\n if (requireApply) setDraft(range);\n else onChange(range);\n };\n\n const handleSelect = (range: DayPickerDateRange | undefined) => {\n if (!range?.from) {\n edit(undefined);\n return;\n }\n\n // Keeps the set time-of-day; otherwise a day click resets it to midnight.\n edit({\n from: current?.from ? withTimeOf(range.from, current.from) : range.from,\n to: range.to && current?.to ? withTimeOf(range.to, current.to) : range.to,\n });\n };\n\n const format =\n formatDate ?? ((date: Date) => (withTime ? `${isoDate(date)} ${timeOf(date)}` : isoDate(date)));\n const triggerLabel = label ?? formatRange(value, format);\n\n return (\n <Popover open={open} defaultOpen={defaultOpen} onOpenChange={handleOpenChange}>\n <Popover.Trigger\n disabled={disabled}\n className={cn(\n overlayTriggerVariants({ variant: isArgoDesign ? 'argo' : variant, sizing: 'medium' }),\n className,\n )}\n >\n <span className={cn('tw:truncate', !triggerLabel && 'tw:text-muted-foreground')}>\n {triggerLabel ?? placeholder}\n </span>\n <ChevronDown className=\"tw:size-4 tw:text-muted-foreground\" />\n </Popover.Trigger>\n <Popover.Content\n align={align}\n alignOffset={alignOffset}\n sideOffset={sideOffset}\n className=\"tw:w-auto tw:p-0\"\n >\n <div className=\"tw:flex\">\n {presets && presets.length > 0 ? (\n <div className=\"tw:flex tw:flex-col tw:gap-1 tw:border-r tw:border-solid tw:border-border tw:p-2\">\n {presets.map((preset) => (\n <Popover.Close asChild key={preset.label}>\n <Button\n variant=\"invisible\"\n size=\"small\"\n className=\"tw:justify-start\"\n onClick={() =>\n onPresetSelect ? onPresetSelect(preset) : onChange(preset.range)\n }\n >\n {preset.label}\n </Button>\n </Popover.Close>\n ))}\n </div>\n ) : null}\n <Calendar\n mode=\"range\"\n selected={current}\n onSelect={handleSelect}\n numberOfMonths={2}\n defaultMonth={current?.from}\n disabled={disabledDays}\n />\n </div>\n {(withTime || requireApply) && (\n <div className=\"tw:flex tw:items-center tw:gap-3 tw:border-t tw:border-solid tw:border-border tw:p-3\">\n {withTime && (\n <>\n <TimeField\n label=\"From\"\n date={current?.from}\n onChange={(time) =>\n current?.from && edit({ ...current, from: atTime(current.from, time) })\n }\n />\n <TimeField\n label=\"To\"\n date={current?.to}\n onChange={(time) =>\n current?.to && edit({ ...current, to: atTime(current.to, time) })\n }\n />\n </>\n )}\n {requireApply && (\n <div className=\"tw:ml-auto tw:flex tw:gap-2\">\n <Popover.Close asChild>\n <Button variant=\"outline\" size=\"small\">\n Cancel\n </Button>\n </Popover.Close>\n <Popover.Close asChild>\n <Button size=\"small\" disabled={!draft?.from} onClick={() => onChange(draft)}>\n Apply\n </Button>\n </Popover.Close>\n </div>\n )}\n </div>\n )}\n </Popover.Content>\n </Popover>\n );\n};\n\nDateRangePicker.displayName = 'DateR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1
- {"version":3,"file":"DiffView-ppTIzh2h.js","names":["variants"],"sources":["../src/components/DiffView/DiffViewMark.tsx","../src/components/DiffView/DiffViewTd.tsx","../src/components/DiffView/DiffViewTh.tsx","../src/components/DiffView/util.ts","../src/components/DiffView/DiffView.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\n// `text-inherit` overrides the UA `mark` colour so the word highlight takes the\n// cell's text colour. That only works if the fill flips with the scheme too —\n// the light pastels are opaque, so under dark they put near-white text on a\n// light slab. Dark mode tints the same hue at a stronger alpha than the line\n// fill behind it, keeping the word-level mark the more prominent of the two.\nconst variants = cva(['tw:p-0.5', 'tw:text-inherit', 'tw:inline-flex'], {\n variants: {\n diff: {\n added: ['tw:bg-green-200', 'tw:[[data-theme=dark]_&]:bg-green-500/40'],\n removed: ['tw:bg-error-300', 'tw:[[data-theme=dark]_&]:bg-error-500/40'],\n },\n },\n});\n\ntype Props = ComponentProps<'span'> & VariantProps<typeof variants>;\n\nexport const DiffViewMark = ({ diff, children, className, ...props }: Props) => (\n <mark {...props} className={cn(variants({ diff, className }))}>\n {children}\n </mark>\n);\n","import type { ComponentProps } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\nconst variants = cva(\n [\n // reset global styles\n 'tw:[&_pre]:p-0',\n 'tw:[&_pre]:m-0',\n 'tw:[&_pre]:border-none',\n 'tw:[&_pre]:rounded-none',\n\n 'tw:align-top',\n // `bg-transparent`, not `bg-inherit`: the cell tints are translucent under\n // the dark scheme, and an inherited `background-color` repaints the same\n // rgba over the already-composited cell — doubling the tint.\n 'tw:[&_pre]:bg-transparent',\n 'tw:[&_pre]:text-inherit',\n 'tw:[&_pre]:px-2',\n 'tw:[&_pre]:!leading-7',\n 'tw:[&_pre]:text-sm',\n 'tw:[&_pre]:whitespace-pre-wrap',\n ],\n {\n defaultVariants: {\n variant: 'default',\n diff: 'default',\n },\n variants: {\n variant: {\n default: [],\n gutter: ['tw:w-14', 'tw:text-right', 'tw:whitespace-nowrap', 'tw:select-none'],\n code: [],\n },\n diff: {\n default: [],\n added: [],\n removed: [],\n },\n },\n // Added/removed rows are meaning-encoding, so they keep the fixed green /\n // error ramps rather than a brand-overridable status token. Both need an\n // explicit light/dark pair: the light pastel washes (`-100`/`-200`) are\n // opaque, so under the dark scheme they stranded the near-white\n // `foreground` on a light slab. Dark mode tints the same hue at low alpha\n // over the pane surface instead, and every cell pins its own text colour —\n // inheriting it left the added/removed code cells invisible in dark mode.\n compoundVariants: [\n {\n variant: 'gutter',\n diff: 'default',\n className: ['tw:bg-muted', 'tw:text-muted-foreground'],\n },\n {\n variant: 'gutter',\n diff: 'added',\n className: [\n // `green-900` (6.1:1 on `green-200`), not `green-600` — that was 2.3:1.\n 'tw:bg-green-200 tw:text-green-900',\n 'tw:[[data-theme=dark]_&]:bg-green-500/25 tw:[[data-theme=dark]_&]:text-green-300',\n ],\n },\n {\n variant: 'gutter',\n diff: 'removed',\n className: [\n // `error-700` (5.4:1 on `error-200`), not `error-500` — that was 3.3:1.\n 'tw:bg-error-200 tw:text-error-700',\n 'tw:[[data-theme=dark]_&]:bg-error-500/25 tw:[[data-theme=dark]_&]:text-error-300',\n ],\n },\n {\n variant: 'code',\n diff: 'default',\n className: ['tw:bg-background', 'tw:text-foreground'],\n },\n {\n variant: 'code',\n diff: 'added',\n className: [\n 'tw:bg-green-100 tw:text-foreground',\n 'tw:[[data-theme=dark]_&]:bg-green-500/15',\n ],\n },\n {\n variant: 'code',\n diff: 'removed',\n className: [\n 'tw:bg-error-100 tw:text-foreground',\n 'tw:[[data-theme=dark]_&]:bg-error-500/15',\n ],\n },\n ],\n },\n);\n\ntype Props = ComponentProps<'td'> & VariantProps<typeof variants>;\n\nexport const DiffViewTd = ({ diff, variant = 'default', children, className, ...props }: Props) => {\n const needsCodeFormatting = variant === 'code' || variant === 'gutter';\n\n return (\n <td {...props} className={cn(variants({ variant, className, diff }))}>\n {needsCodeFormatting ? <pre>{children}</pre> : children}\n </td>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'th'> & {\n variant?: 'default' | 'gutter';\n};\n\nexport const DiffViewTh = ({ variant = 'default', children, className, ...props }: Props) => (\n <th\n {...props}\n className={cn(\n 'tw:bg-background',\n 'tw:py-3',\n // explicit `border-border`: v4 changed the default border color from gray-200 to\n // `currentColor`, so a bare `border-b` rendered a dark divider (the th's text colour)\n // instead of the light-grey header rule.\n 'tw:border-b',\n 'tw:border-border',\n { 'tw:w-14': variant === 'gutter' },\n { 'tw:last:pr-8': variant === 'default' },\n className,\n )}\n >\n {children}\n </th>\n);\n","import { diffLines, diffWords } from 'diff';\n\nexport const DiffType = {\n DEFAULT: 'default',\n ADDED: 'added',\n REMOVED: 'removed',\n} as const;\n\ntype DiffTypeValue = (typeof DiffType)[keyof typeof DiffType];\n\nexport type DiffInformation = {\n value: string | DiffInformation[];\n lineNumber: number;\n type: DiffTypeValue;\n};\n\nexport type LineInformation = {\n left: DiffInformation;\n right: DiffInformation;\n};\n\ntype ComputedLineInformation = {\n lineInformation: LineInformation[];\n diffLines: number[];\n};\n\ntype SidedDiffInformation = {\n left: DiffInformation[];\n right: DiffInformation[];\n};\n\nexport type WordInformation = {\n value: string;\n type: DiffTypeValue;\n lineNumber: number;\n};\n\nexport type SideInformation = {\n type: DiffTypeValue;\n lineNumber: number;\n words: WordInformation[];\n};\n\nexport type DiffRow =\n | { kind: 'fold'; blockStart: number; lineCount: number; key: string }\n | { kind: 'line'; left: SideInformation; right: SideInformation; key: string };\n\nconst EXTRA_LINES = 3;\n\n// Sentinel blockStart for the region after the last diff; keeps distance checks\n// inert and lets `expandedBlocks` key on a real value.\nconst TAIL_BLOCK = Number.POSITIVE_INFINITY;\n\ntype Counters = {\n left: number;\n right: number;\n global: number;\n};\n\ntype DiffChunk = ReturnType<typeof diffLines>[number];\n\nconst splitLines = (value: string): string[] => {\n if (value === '') return [];\n return value.replace(/\\n$/, '').split('\\n');\n};\n\nconst computeWordDiff = (oldValue: string, newValue: string): SidedDiffInformation => {\n const result: SidedDiffInformation = { left: [], right: [] };\n\n diffWords(oldValue, newValue).forEach(({ added, removed, value }) => {\n if (added) {\n result.right.push({ type: DiffType.ADDED, value, lineNumber: 0 });\n return;\n }\n if (removed) {\n result.left.push({ type: DiffType.REMOVED, value, lineNumber: 0 });\n return;\n }\n const unchanged: DiffInformation = { type: DiffType.DEFAULT, value, lineNumber: 0 };\n result.right.push(unchanged);\n result.left.push(unchanged);\n });\n\n return result;\n};\n\n// Look ahead one chunk in the diff array and return the paired added-line string,\n// or null if there isn't one at the same lineIndex position.\nconst findPairedAddedLine = (\n diffArray: DiffChunk[],\n blockIndex: number,\n lineIndex: number,\n): string | null => {\n const nextBlock = diffArray[blockIndex + 1];\n if (!nextBlock?.added) return null;\n return splitLines(nextBlock.value)[lineIndex] ?? null;\n};\n\nconst buildUnchangedLine = (value: string, counters: Counters): LineInformation => {\n counters.left += 1;\n counters.right += 1;\n return {\n left: { type: DiffType.DEFAULT, value, lineNumber: counters.left },\n right: { type: DiffType.DEFAULT, value, lineNumber: counters.right },\n };\n};\n\nconst buildAddedLine = (value: string, counters: Counters): LineInformation => {\n counters.right += 1;\n return {\n left: {} as DiffInformation,\n right: { type: DiffType.ADDED, value, lineNumber: counters.right },\n };\n};\n\nconst buildRemovedLine = (value: string, counters: Counters): LineInformation => {\n counters.left += 1;\n return {\n left: { type: DiffType.REMOVED, value: value || ' ', lineNumber: counters.left },\n right: {} as DiffInformation,\n };\n};\n\n// Removed + paired added → one modification row with word-level diff.\n// Returns `isActualChange: false` for the quirky case where the two sides\n// resolve to the same string; the caller then omits it from diffLines.\nconst buildModifiedLine = (\n leftValue: string,\n rightValue: string,\n counters: Counters,\n): { line: LineInformation; isActualChange: boolean } => {\n counters.left += 1;\n counters.right += 1;\n const displayLeft = leftValue || ' ';\n\n if (displayLeft === rightValue) {\n return {\n line: {\n left: { type: DiffType.DEFAULT, value: rightValue, lineNumber: counters.left },\n right: { type: DiffType.DEFAULT, value: rightValue, lineNumber: counters.right },\n },\n isActualChange: false,\n };\n }\n\n const { left, right } = computeWordDiff(leftValue, rightValue);\n return {\n line: {\n left: { type: DiffType.REMOVED, value: left, lineNumber: counters.left },\n right: { type: DiffType.ADDED, value: right, lineNumber: counters.right },\n },\n isActualChange: true,\n };\n};\n\nexport const computeLineInformation = (\n oldString: string,\n newString: string,\n ignoreWhitespace?: boolean,\n): ComputedLineInformation => {\n const diffArray = diffLines(oldString.trimEnd(), newString.trimEnd(), { ignoreWhitespace });\n const counters: Counters = { left: 0, right: 0, global: 0 };\n const lineInformation: LineInformation[] = [];\n const diffLineSet = new Set<number>();\n const consumedAddedLines = new Set<string>();\n\n diffArray.forEach((block, blockIndex) => {\n splitLines(block.value).forEach((value, lineIndex) => {\n if (consumedAddedLines.has(`${blockIndex}-${lineIndex}`)) return;\n\n if (block.removed) {\n const paired = findPairedAddedLine(diffArray, blockIndex, lineIndex);\n if (paired !== null) {\n consumedAddedLines.add(`${blockIndex + 1}-${lineIndex}`);\n const { line, isActualChange } = buildModifiedLine(value, paired, counters);\n lineInformation.push(line);\n if (isActualChange) diffLineSet.add(counters.global);\n } else {\n lineInformation.push(buildRemovedLine(value, counters));\n diffLineSet.add(counters.global);\n }\n } else if (block.added) {\n lineInformation.push(buildAddedLine(value, counters));\n diffLineSet.add(counters.global);\n } else {\n lineInformation.push(buildUnchangedLine(value, counters));\n }\n\n counters.global += 1;\n });\n });\n\n return {\n lineInformation,\n diffLines: [...diffLineSet].sort((a, b) => a - b),\n };\n};\n\ntype ContextSegment = { kind: 'context'; lines: LineInformation[]; firstIndex: number };\ntype ChangeSegment = { kind: 'change'; lines: LineInformation[]; firstIndex: number };\ntype Segment = ContextSegment | ChangeSegment;\n\nconst toSegments = (\n lineInformation: LineInformation[],\n diffLineSet: ReadonlySet<number>,\n): Segment[] => {\n const segments: Segment[] = [];\n let current: Segment | null = null;\n\n lineInformation.forEach((line, index) => {\n const isChange = diffLineSet.has(index);\n if (current === null || (current.kind === 'change') !== isChange) {\n current = isChange\n ? { kind: 'change', lines: [line], firstIndex: index }\n : { kind: 'context', lines: [line], firstIndex: index };\n segments.push(current);\n } else {\n current.lines.push(line);\n }\n });\n\n return segments;\n};\n\nconst normalizeSide = (side: DiffInformation): SideInformation => {\n const raw = Array.isArray(side.value)\n ? side.value\n : [{ value: side.value, type: DiffType.DEFAULT, lineNumber: 0 }];\n\n return {\n type: side.type,\n lineNumber: side.lineNumber,\n words: raw.filter((w): w is WordInformation => typeof w.value === 'string'),\n };\n};\n\nconst renderLineRow = (line: LineInformation): DiffRow => ({\n kind: 'line',\n left: normalizeSide(line.left),\n right: normalizeSide(line.right),\n key: `${line.left.lineNumber}-${line.right.lineNumber}`,\n});\n\nconst renderContextSegment = (\n segment: ContextSegment,\n nextChangeIndex: number,\n hasPrevChange: boolean,\n hasNextChange: boolean,\n expanded: ReadonlySet<number>,\n): DiffRow[] => {\n if (expanded.has(nextChangeIndex)) {\n return segment.lines.map(renderLineRow);\n }\n\n const total = segment.lines.length;\n const trail = hasPrevChange ? Math.min(EXTRA_LINES, total) : 0;\n let lead = hasNextChange ? Math.min(EXTRA_LINES, total - trail) : 0;\n let foldCount = total - trail - lead;\n\n // Quirk from the original: a single trailing unchanged line is always rendered\n // (no one-line fold at the tail). Absorb it into the lead slice.\n if (!hasNextChange && foldCount === 1) {\n foldCount = 0;\n lead = 1;\n }\n\n const rows: DiffRow[] = [];\n if (trail > 0) {\n rows.push(...segment.lines.slice(0, trail).map(renderLineRow));\n }\n if (foldCount > 0) {\n rows.push({\n kind: 'fold',\n blockStart: nextChangeIndex,\n lineCount: foldCount,\n key: hasNextChange\n ? `fold-${nextChangeIndex}`\n : `fold-tail-${segment.firstIndex + total - 1}`,\n });\n }\n if (lead > 0) {\n rows.push(...segment.lines.slice(trail + foldCount).map(renderLineRow));\n }\n return rows;\n};\n\nexport const computeDiffRows = (\n lineInformation: LineInformation[],\n diffLines: number[],\n expandedBlocks: number[],\n): DiffRow[] => {\n const diffLineSet = new Set(diffLines);\n const expanded = new Set(expandedBlocks);\n const segments = toSegments(lineInformation, diffLineSet);\n\n const rows: DiffRow[] = [];\n let hasPrevChange = false;\n\n segments.forEach((segment, i) => {\n if (segment.kind === 'change') {\n rows.push(...segment.lines.map(renderLineRow));\n hasPrevChange = true;\n return;\n }\n const nextChange = segments.slice(i + 1).find((s) => s.kind === 'change');\n const nextStart = nextChange?.firstIndex ?? TAIL_BLOCK;\n rows.push(...renderContextSegment(segment, nextStart, hasPrevChange, !!nextChange, expanded));\n });\n\n return rows;\n};\n","import { useState } from 'react';\nimport type { ReactNode } from 'react';\n\nimport { cn } from '../../utils';\n\nimport { DiffViewMark } from './DiffViewMark';\nimport { DiffViewTd } from './DiffViewTd';\nimport { DiffViewTh } from './DiffViewTh';\nimport { computeDiffRows, computeLineInformation } from './util';\n\ntype Props = {\n oldValue: string;\n newValue: string;\n ignoreWhitespace?: boolean;\n className?: string;\n\n leftTitleGutter?: ReactNode;\n leftTitle: ReactNode;\n rightTitle: ReactNode;\n rightTitleGutter?: ReactNode;\n};\n\nexport const DiffView = ({\n leftTitle,\n leftTitleGutter,\n rightTitle,\n rightTitleGutter,\n oldValue,\n newValue,\n ignoreWhitespace,\n className,\n}: Props) => {\n const [expandedBlocks, setExpandedBlocks] = useState<number[]>([]);\n const { lineInformation, diffLines } = computeLineInformation(\n oldValue,\n newValue,\n ignoreWhitespace,\n );\n const rows = computeDiffRows(lineInformation, diffLines, expandedBlocks);\n\n const handleExpand = (blockNumber: number) => {\n setExpandedBlocks((curr) => [...curr, blockNumber]);\n };\n\n return (\n <div\n className={cn(\n 'tailwindcss-preflight',\n 'tw:bg-muted',\n // Pin the text colour rather than inheriting it: the diff is routinely\n // portalled into a Modal, where an inherited colour comes from whatever\n // sits above the portal root instead of this surface.\n 'tw:text-foreground',\n // explicit `border-border` — v4's default border colour is `currentColor`, so a bare\n // `border` drew a dark frame instead of the light-grey outline.\n 'tw:border',\n 'tw:border-border',\n 'tw:rounded-2xl',\n 'tw:overflow-auto',\n className,\n )}\n >\n <table className=\"tw:w-full tw:table-fixed tw:bg-background\">\n {/* Not v4's `shadow-xs`: `tailwind-config`'s `boxShadow.sm` fallback still carries\n the v3 value, and only `shadow-sm` reads `--shadow-sm` from a brand's\n `theme.shadows` — `shadow-xs` has no token and would opt this header out. */}\n <thead className=\"tw:sticky tw:top-0 tw:z-10 tw:shadow-sm\">\n <tr>\n <DiffViewTh variant=\"gutter\">{leftTitleGutter}</DiffViewTh>\n <DiffViewTh>{leftTitle}</DiffViewTh>\n <DiffViewTh variant=\"gutter\">{rightTitleGutter}</DiffViewTh>\n <DiffViewTh>{rightTitle}</DiffViewTh>\n </tr>\n </thead>\n\n <tbody>\n {rows.map((row) => {\n if (row.kind === 'fold')\n return (\n <tr key={row.key}>\n <DiffViewTd colSpan={4}>\n <button\n type=\"button\"\n onClick={() => handleExpand(row.blockStart)}\n className={cn(\n 'tw:w-full',\n 'tw:text-center',\n 'tw:bg-muted',\n 'tw:text-foreground',\n 'tw:hover:bg-accent',\n 'tw:underline',\n 'tw:p-2',\n )}\n >\n Expand {row.lineCount} lines ...\n </button>\n </DiffViewTd>\n </tr>\n );\n\n return (\n <tr key={row.key}>\n <DiffViewTd variant=\"gutter\" diff={row.left.type}>\n {row.left.lineNumber}\n </DiffViewTd>\n\n <DiffViewTd variant=\"code\" diff={row.left.type}>\n {row.left.words.map((val, index) => {\n if (val.type === 'default') return val.value;\n return (\n // oxlint-disable-next-line react/no-array-index-key\n <DiffViewMark key={`${val.value}-${val.type}-${index}`} diff={val.type}>\n {val.value}\n </DiffViewMark>\n );\n })}\n </DiffViewTd>\n\n <DiffViewTd variant=\"gutter\" diff={row.right.type}>\n {row.right.lineNumber}\n </DiffViewTd>\n\n <DiffViewTd variant=\"code\" diff={row.right.type}>\n {row.right.words.map((val, index) => {\n if (val.type === 'default') return val.value;\n\n return (\n // oxlint-disable-next-line react/no-array-index-key\n <DiffViewMark key={`${val.value}-${val.type}-${index}`} diff={val.type}>\n {val.value}\n </DiffViewMark>\n );\n })}\n </DiffViewTd>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n};\n"],"mappings":";;;;;;AAUA,MAAMA,aAAW,IAAI;CAAC;CAAY;CAAmB;AAAgB,GAAG,EACtE,UAAU,EACR,MAAM;CACJ,OAAO,CAAC,mBAAmB,0CAA0C;CACrE,SAAS,CAAC,mBAAmB,0CAA0C;AACzE,EACF,EACF,CAAC;AAID,MAAa,gBAAgB,EAAE,MAAM,UAAU,WAAW,GAAG,YAC3D,oBAAC,QAAD;CAAM,GAAI;CAAO,WAAW,GAAGA,WAAS;EAAE;EAAM;CAAU,CAAC,CAAC;CACzD;AACG,CAAA;;;ACnBR,MAAM,WAAW,IACf;CAEE;CACA;CACA;CACA;CAEA;CAIA;CACA;CACA;CACA;CACA;CACA;AACF,GACA;CACE,iBAAiB;EACf,SAAS;EACT,MAAM;CACR;CACA,UAAU;EACR,SAAS;GACP,SAAS,CAAC;GACV,QAAQ;IAAC;IAAW;IAAiB;IAAwB;GAAgB;GAC7E,MAAM,CAAC;EACT;EACA,MAAM;GACJ,SAAS,CAAC;GACV,OAAO,CAAC;GACR,SAAS,CAAC;EACZ;CACF;CAQA,kBAAkB;EAChB;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAAC,eAAe,0BAA0B;EACvD;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAET,qCACA,kFACF;EACF;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAET,qCACA,kFACF;EACF;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAAC,oBAAoB,oBAAoB;EACtD;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CACT,sCACA,0CACF;EACF;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CACT,sCACA,0CACF;EACF;CACF;AACF,CACF;AAIA,MAA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,UAAU;OACnC,IAAI,IAAI,SAAS,WAAW,OAAO,IAAI;OAEvC,OAEE,oBAAC,cAAD;QAAwD,MAAM,IAAI;QAC/D,UAAA,IAAI;OACO,GAFK,GAAG,IAAI,MAAM,GAAG,IAAI,KAAK,GAAG,OAEjC;MAElB,CAAC;KACS,CAAA;IACV,EAAA,GAjCK,IAAI,GAiCT;GAER,CAAC,EACI,CAAA,CACF;;CACJ,CAAA;AAET"}
1
+ {"version":3,"file":"DiffView-ppTIzh2h.js","names":["variants"],"sources":["../src/components/DiffView/DiffViewMark.tsx","../src/components/DiffView/DiffViewTd.tsx","../src/components/DiffView/DiffViewTh.tsx","../src/components/DiffView/util.ts","../src/components/DiffView/DiffView.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\n// `text-inherit` overrides the UA `mark` colour so the word highlight takes the\n// cell's text colour. That only works if the fill flips with the scheme too —\n// the light pastels are opaque, so under dark they put near-white text on a\n// light slab. Dark mode tints the same hue at a stronger alpha than the line\n// fill behind it, keeping the word-level mark the more prominent of the two.\nconst variants = cva(['tw:p-0.5', 'tw:text-inherit', 'tw:inline-flex'], {\n variants: {\n diff: {\n added: ['tw:bg-green-200', 'tw:[[data-theme=dark]_&]:bg-green-500/40'],\n removed: ['tw:bg-error-300', 'tw:[[data-theme=dark]_&]:bg-error-500/40'],\n },\n },\n});\n\ntype Props = ComponentProps<'span'> & VariantProps<typeof variants>;\n\nexport const DiffViewMark = ({ diff, children, className, ...props }: Props) => (\n <mark {...props} className={cn(variants({ diff, className }))}>\n {children}\n </mark>\n);\n","import type { ComponentProps } from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\nconst variants = cva(\n [\n // reset global styles\n 'tw:[&_pre]:p-0',\n 'tw:[&_pre]:m-0',\n 'tw:[&_pre]:border-none',\n 'tw:[&_pre]:rounded-none',\n\n 'tw:align-top',\n // Not `bg-inherit`: the translucent dark-mode tint would paint twice.\n 'tw:[&_pre]:bg-transparent',\n 'tw:[&_pre]:text-inherit',\n 'tw:[&_pre]:px-2',\n 'tw:[&_pre]:!leading-7',\n 'tw:[&_pre]:text-sm',\n 'tw:[&_pre]:whitespace-pre-wrap',\n ],\n {\n defaultVariants: {\n variant: 'default',\n diff: 'default',\n },\n variants: {\n variant: {\n default: [],\n gutter: ['tw:w-14', 'tw:text-right', 'tw:whitespace-nowrap', 'tw:select-none'],\n code: [],\n },\n diff: {\n default: [],\n added: [],\n removed: [],\n },\n },\n // Fixed green/error ramps, not brand-overridable status tokens.\n // Each needs a light/dark pair and its own text colour, or dark mode hides the text.\n compoundVariants: [\n {\n variant: 'gutter',\n diff: 'default',\n className: ['tw:bg-muted', 'tw:text-muted-foreground'],\n },\n {\n variant: 'gutter',\n diff: 'added',\n className: [\n // `green-900` for contrast (6.1:1 on `green-200`).\n 'tw:bg-green-200 tw:text-green-900',\n 'tw:[[data-theme=dark]_&]:bg-green-500/25 tw:[[data-theme=dark]_&]:text-green-300',\n ],\n },\n {\n variant: 'gutter',\n diff: 'removed',\n className: [\n // `error-700` for contrast (5.4:1 on `error-200`).\n 'tw:bg-error-200 tw:text-error-700',\n 'tw:[[data-theme=dark]_&]:bg-error-500/25 tw:[[data-theme=dark]_&]:text-error-300',\n ],\n },\n {\n variant: 'code',\n diff: 'default',\n className: ['tw:bg-background', 'tw:text-foreground'],\n },\n {\n variant: 'code',\n diff: 'added',\n className: [\n 'tw:bg-green-100 tw:text-foreground',\n 'tw:[[data-theme=dark]_&]:bg-green-500/15',\n ],\n },\n {\n variant: 'code',\n diff: 'removed',\n className: [\n 'tw:bg-error-100 tw:text-foreground',\n 'tw:[[data-theme=dark]_&]:bg-error-500/15',\n ],\n },\n ],\n },\n);\n\ntype Props = ComponentProps<'td'> & VariantProps<typeof variants>;\n\nexport const DiffViewTd = ({ diff, variant = 'default', children, className, ...props }: Props) => {\n const needsCodeFormatting = variant === 'code' || variant === 'gutter';\n\n return (\n <td {...props} className={cn(variants({ variant, className, diff }))}>\n {needsCodeFormatting ? <pre>{children}</pre> : children}\n </td>\n );\n};\n","import type { ComponentProps } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'th'> & {\n variant?: 'default' | 'gutter';\n};\n\nexport const DiffViewTh = ({ variant = 'default', children, className, ...props }: Props) => (\n <th\n {...props}\n className={cn(\n 'tw:bg-background',\n 'tw:py-3',\n // explicit `border-border`: v4 changed the default border color from gray-200 to\n // `currentColor`, so a bare `border-b` rendered a dark divider (the th's text colour)\n // instead of the light-grey header rule.\n 'tw:border-b',\n 'tw:border-border',\n { 'tw:w-14': variant === 'gutter' },\n { 'tw:last:pr-8': variant === 'default' },\n className,\n )}\n >\n {children}\n </th>\n);\n","import { diffLines, diffWords } from 'diff';\n\nexport const DiffType = {\n DEFAULT: 'default',\n ADDED: 'added',\n REMOVED: 'removed',\n} as const;\n\ntype DiffTypeValue = (typeof DiffType)[keyof typeof DiffType];\n\nexport type DiffInformation = {\n value: string | DiffInformation[];\n lineNumber: number;\n type: DiffTypeValue;\n};\n\nexport type LineInformation = {\n left: DiffInformation;\n right: DiffInformation;\n};\n\ntype ComputedLineInformation = {\n lineInformation: LineInformation[];\n diffLines: number[];\n};\n\ntype SidedDiffInformation = {\n left: DiffInformation[];\n right: DiffInformation[];\n};\n\nexport type WordInformation = {\n value: string;\n type: DiffTypeValue;\n lineNumber: number;\n};\n\nexport type SideInformation = {\n type: DiffTypeValue;\n lineNumber: number;\n words: WordInformation[];\n};\n\nexport type DiffRow =\n | { kind: 'fold'; blockStart: number; lineCount: number; key: string }\n | { kind: 'line'; left: SideInformation; right: SideInformation; key: string };\n\nconst EXTRA_LINES = 3;\n\n// Sentinel blockStart for the region after the last diff; keeps distance checks\n// inert and lets `expandedBlocks` key on a real value.\nconst TAIL_BLOCK = Number.POSITIVE_INFINITY;\n\ntype Counters = {\n left: number;\n right: number;\n global: number;\n};\n\ntype DiffChunk = ReturnType<typeof diffLines>[number];\n\nconst splitLines = (value: string): string[] => {\n if (value === '') return [];\n return value.replace(/\\n$/, '').split('\\n');\n};\n\nconst computeWordDiff = (oldValue: string, newValue: string): SidedDiffInformation => {\n const result: SidedDiffInformation = { left: [], right: [] };\n\n diffWords(oldValue, newValue).forEach(({ added, removed, value }) => {\n if (added) {\n result.right.push({ type: DiffType.ADDED, value, lineNumber: 0 });\n return;\n }\n if (removed) {\n result.left.push({ type: DiffType.REMOVED, value, lineNumber: 0 });\n return;\n }\n const unchanged: DiffInformation = { type: DiffType.DEFAULT, value, lineNumber: 0 };\n result.right.push(unchanged);\n result.left.push(unchanged);\n });\n\n return result;\n};\n\n// Look ahead one chunk in the diff array and return the paired added-line string,\n// or null if there isn't one at the same lineIndex position.\nconst findPairedAddedLine = (\n diffArray: DiffChunk[],\n blockIndex: number,\n lineIndex: number,\n): string | null => {\n const nextBlock = diffArray[blockIndex + 1];\n if (!nextBlock?.added) return null;\n return splitLines(nextBlock.value)[lineIndex] ?? null;\n};\n\nconst buildUnchangedLine = (value: string, counters: Counters): LineInformation => {\n counters.left += 1;\n counters.right += 1;\n return {\n left: { type: DiffType.DEFAULT, value, lineNumber: counters.left },\n right: { type: DiffType.DEFAULT, value, lineNumber: counters.right },\n };\n};\n\nconst buildAddedLine = (value: string, counters: Counters): LineInformation => {\n counters.right += 1;\n return {\n left: {} as DiffInformation,\n right: { type: DiffType.ADDED, value, lineNumber: counters.right },\n };\n};\n\nconst buildRemovedLine = (value: string, counters: Counters): LineInformation => {\n counters.left += 1;\n return {\n left: { type: DiffType.REMOVED, value: value || ' ', lineNumber: counters.left },\n right: {} as DiffInformation,\n };\n};\n\n// Removed + paired added → one modification row with word-level diff.\n// Returns `isActualChange: false` for the quirky case where the two sides\n// resolve to the same string; the caller then omits it from diffLines.\nconst buildModifiedLine = (\n leftValue: string,\n rightValue: string,\n counters: Counters,\n): { line: LineInformation; isActualChange: boolean } => {\n counters.left += 1;\n counters.right += 1;\n const displayLeft = leftValue || ' ';\n\n if (displayLeft === rightValue) {\n return {\n line: {\n left: { type: DiffType.DEFAULT, value: rightValue, lineNumber: counters.left },\n right: { type: DiffType.DEFAULT, value: rightValue, lineNumber: counters.right },\n },\n isActualChange: false,\n };\n }\n\n const { left, right } = computeWordDiff(leftValue, rightValue);\n return {\n line: {\n left: { type: DiffType.REMOVED, value: left, lineNumber: counters.left },\n right: { type: DiffType.ADDED, value: right, lineNumber: counters.right },\n },\n isActualChange: true,\n };\n};\n\nexport const computeLineInformation = (\n oldString: string,\n newString: string,\n ignoreWhitespace?: boolean,\n): ComputedLineInformation => {\n const diffArray = diffLines(oldString.trimEnd(), newString.trimEnd(), { ignoreWhitespace });\n const counters: Counters = { left: 0, right: 0, global: 0 };\n const lineInformation: LineInformation[] = [];\n const diffLineSet = new Set<number>();\n const consumedAddedLines = new Set<string>();\n\n diffArray.forEach((block, blockIndex) => {\n splitLines(block.value).forEach((value, lineIndex) => {\n if (consumedAddedLines.has(`${blockIndex}-${lineIndex}`)) return;\n\n if (block.removed) {\n const paired = findPairedAddedLine(diffArray, blockIndex, lineIndex);\n if (paired !== null) {\n consumedAddedLines.add(`${blockIndex + 1}-${lineIndex}`);\n const { line, isActualChange } = buildModifiedLine(value, paired, counters);\n lineInformation.push(line);\n if (isActualChange) diffLineSet.add(counters.global);\n } else {\n lineInformation.push(buildRemovedLine(value, counters));\n diffLineSet.add(counters.global);\n }\n } else if (block.added) {\n lineInformation.push(buildAddedLine(value, counters));\n diffLineSet.add(counters.global);\n } else {\n lineInformation.push(buildUnchangedLine(value, counters));\n }\n\n counters.global += 1;\n });\n });\n\n return {\n lineInformation,\n diffLines: [...diffLineSet].sort((a, b) => a - b),\n };\n};\n\ntype ContextSegment = { kind: 'context'; lines: LineInformation[]; firstIndex: number };\ntype ChangeSegment = { kind: 'change'; lines: LineInformation[]; firstIndex: number };\ntype Segment = ContextSegment | ChangeSegment;\n\nconst toSegments = (\n lineInformation: LineInformation[],\n diffLineSet: ReadonlySet<number>,\n): Segment[] => {\n const segments: Segment[] = [];\n let current: Segment | null = null;\n\n lineInformation.forEach((line, index) => {\n const isChange = diffLineSet.has(index);\n if (current === null || (current.kind === 'change') !== isChange) {\n current = isChange\n ? { kind: 'change', lines: [line], firstIndex: index }\n : { kind: 'context', lines: [line], firstIndex: index };\n segments.push(current);\n } else {\n current.lines.push(line);\n }\n });\n\n return segments;\n};\n\nconst normalizeSide = (side: DiffInformation): SideInformation => {\n const raw = Array.isArray(side.value)\n ? side.value\n : [{ value: side.value, type: DiffType.DEFAULT, lineNumber: 0 }];\n\n return {\n type: side.type,\n lineNumber: side.lineNumber,\n words: raw.filter((w): w is WordInformation => typeof w.value === 'string'),\n };\n};\n\nconst renderLineRow = (line: LineInformation): DiffRow => ({\n kind: 'line',\n left: normalizeSide(line.left),\n right: normalizeSide(line.right),\n key: `${line.left.lineNumber}-${line.right.lineNumber}`,\n});\n\nconst renderContextSegment = (\n segment: ContextSegment,\n nextChangeIndex: number,\n hasPrevChange: boolean,\n hasNextChange: boolean,\n expanded: ReadonlySet<number>,\n): DiffRow[] => {\n if (expanded.has(nextChangeIndex)) {\n return segment.lines.map(renderLineRow);\n }\n\n const total = segment.lines.length;\n const trail = hasPrevChange ? Math.min(EXTRA_LINES, total) : 0;\n let lead = hasNextChange ? Math.min(EXTRA_LINES, total - trail) : 0;\n let foldCount = total - trail - lead;\n\n // Quirk from the original: a single trailing unchanged line is always rendered\n // (no one-line fold at the tail). Absorb it into the lead slice.\n if (!hasNextChange && foldCount === 1) {\n foldCount = 0;\n lead = 1;\n }\n\n const rows: DiffRow[] = [];\n if (trail > 0) {\n rows.push(...segment.lines.slice(0, trail).map(renderLineRow));\n }\n if (foldCount > 0) {\n rows.push({\n kind: 'fold',\n blockStart: nextChangeIndex,\n lineCount: foldCount,\n key: hasNextChange\n ? `fold-${nextChangeIndex}`\n : `fold-tail-${segment.firstIndex + total - 1}`,\n });\n }\n if (lead > 0) {\n rows.push(...segment.lines.slice(trail + foldCount).map(renderLineRow));\n }\n return rows;\n};\n\nexport const computeDiffRows = (\n lineInformation: LineInformation[],\n diffLines: number[],\n expandedBlocks: number[],\n): DiffRow[] => {\n const diffLineSet = new Set(diffLines);\n const expanded = new Set(expandedBlocks);\n const segments = toSegments(lineInformation, diffLineSet);\n\n const rows: DiffRow[] = [];\n let hasPrevChange = false;\n\n segments.forEach((segment, i) => {\n if (segment.kind === 'change') {\n rows.push(...segment.lines.map(renderLineRow));\n hasPrevChange = true;\n return;\n }\n const nextChange = segments.slice(i + 1).find((s) => s.kind === 'change');\n const nextStart = nextChange?.firstIndex ?? TAIL_BLOCK;\n rows.push(...renderContextSegment(segment, nextStart, hasPrevChange, !!nextChange, expanded));\n });\n\n return rows;\n};\n","import { useState } from 'react';\nimport type { ReactNode } from 'react';\n\nimport { cn } from '../../utils';\n\nimport { DiffViewMark } from './DiffViewMark';\nimport { DiffViewTd } from './DiffViewTd';\nimport { DiffViewTh } from './DiffViewTh';\nimport { computeDiffRows, computeLineInformation } from './util';\n\ntype Props = {\n oldValue: string;\n newValue: string;\n ignoreWhitespace?: boolean;\n className?: string;\n\n leftTitleGutter?: ReactNode;\n leftTitle: ReactNode;\n rightTitle: ReactNode;\n rightTitleGutter?: ReactNode;\n};\n\nexport const DiffView = ({\n leftTitle,\n leftTitleGutter,\n rightTitle,\n rightTitleGutter,\n oldValue,\n newValue,\n ignoreWhitespace,\n className,\n}: Props) => {\n const [expandedBlocks, setExpandedBlocks] = useState<number[]>([]);\n const { lineInformation, diffLines } = computeLineInformation(\n oldValue,\n newValue,\n ignoreWhitespace,\n );\n const rows = computeDiffRows(lineInformation, diffLines, expandedBlocks);\n\n const handleExpand = (blockNumber: number) => {\n setExpandedBlocks((curr) => [...curr, blockNumber]);\n };\n\n return (\n <div\n className={cn(\n 'tailwindcss-preflight',\n 'tw:bg-muted',\n // Pin the text colour rather than inheriting it: the diff is routinely\n // portalled into a Modal, where an inherited colour comes from whatever\n // sits above the portal root instead of this surface.\n 'tw:text-foreground',\n // explicit `border-border` — v4's default border colour is `currentColor`, so a bare\n // `border` drew a dark frame instead of the light-grey outline.\n 'tw:border',\n 'tw:border-border',\n 'tw:rounded-2xl',\n 'tw:overflow-auto',\n className,\n )}\n >\n <table className=\"tw:w-full tw:table-fixed tw:bg-background\">\n {/* Not v4's `shadow-xs`: `tailwind-config`'s `boxShadow.sm` fallback still carries\n the v3 value, and only `shadow-sm` reads `--shadow-sm` from a brand's\n `theme.shadows` — `shadow-xs` has no token and would opt this header out. */}\n <thead className=\"tw:sticky tw:top-0 tw:z-10 tw:shadow-sm\">\n <tr>\n <DiffViewTh variant=\"gutter\">{leftTitleGutter}</DiffViewTh>\n <DiffViewTh>{leftTitle}</DiffViewTh>\n <DiffViewTh variant=\"gutter\">{rightTitleGutter}</DiffViewTh>\n <DiffViewTh>{rightTitle}</DiffViewTh>\n </tr>\n </thead>\n\n <tbody>\n {rows.map((row) => {\n if (row.kind === 'fold')\n return (\n <tr key={row.key}>\n <DiffViewTd colSpan={4}>\n <button\n type=\"button\"\n onClick={() => handleExpand(row.blockStart)}\n className={cn(\n 'tw:w-full',\n 'tw:text-center',\n 'tw:bg-muted',\n 'tw:text-foreground',\n 'tw:hover:bg-accent',\n 'tw:underline',\n 'tw:p-2',\n )}\n >\n Expand {row.lineCount} lines ...\n </button>\n </DiffViewTd>\n </tr>\n );\n\n return (\n <tr key={row.key}>\n <DiffViewTd variant=\"gutter\" diff={row.left.type}>\n {row.left.lineNumber}\n </DiffViewTd>\n\n <DiffViewTd variant=\"code\" diff={row.left.type}>\n {row.left.words.map((val, index) => {\n if (val.type === 'default') return val.value;\n return (\n // oxlint-disable-next-line react/no-array-index-key\n <DiffViewMark key={`${val.value}-${val.type}-${index}`} diff={val.type}>\n {val.value}\n </DiffViewMark>\n );\n })}\n </DiffViewTd>\n\n <DiffViewTd variant=\"gutter\" diff={row.right.type}>\n {row.right.lineNumber}\n </DiffViewTd>\n\n <DiffViewTd variant=\"code\" diff={row.right.type}>\n {row.right.words.map((val, index) => {\n if (val.type === 'default') return val.value;\n\n return (\n // oxlint-disable-next-line react/no-array-index-key\n <DiffViewMark key={`${val.value}-${val.type}-${index}`} diff={val.type}>\n {val.value}\n </DiffViewMark>\n );\n })}\n </DiffViewTd>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n};\n"],"mappings":";;;;;;AAUA,MAAMA,aAAW,IAAI;CAAC;CAAY;CAAmB;AAAgB,GAAG,EACtE,UAAU,EACR,MAAM;CACJ,OAAO,CAAC,mBAAmB,0CAA0C;CACrE,SAAS,CAAC,mBAAmB,0CAA0C;AACzE,EACF,EACF,CAAC;AAID,MAAa,gBAAgB,EAAE,MAAM,UAAU,WAAW,GAAG,YAC3D,oBAAC,QAAD;CAAM,GAAI;CAAO,WAAW,GAAGA,WAAS;EAAE;EAAM;CAAU,CAAC,CAAC;CACzD;AACG,CAAA;;;ACnBR,MAAM,WAAW,IACf;CAEE;CACA;CACA;CACA;CAEA;CAEA;CACA;CACA;CACA;CACA;CACA;AACF,GACA;CACE,iBAAiB;EACf,SAAS;EACT,MAAM;CACR;CACA,UAAU;EACR,SAAS;GACP,SAAS,CAAC;GACV,QAAQ;IAAC;IAAW;IAAiB;IAAwB;GAAgB;GAC7E,MAAM,CAAC;EACT;EACA,MAAM;GACJ,SAAS,CAAC;GACV,OAAO,CAAC;GACR,SAAS,CAAC;EACZ;CACF;CAGA,kBAAkB;EAChB;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAAC,eAAe,0BAA0B;EACvD;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAET,qCACA,kFACF;EACF;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAET,qCACA,kFACF;EACF;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CAAC,oBAAoB,oBAAoB;EACtD;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CACT,sCACA,0CACF;EACF;EACA;GACE,SAAS;GACT,MAAM;GACN,WAAW,CACT,sCACA,0C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AA,IAAI,MAAM,MAAM,KAAK,KAAK,UAAU;OACnC,IAAI,IAAI,SAAS,WAAW,OAAO,IAAI;OAEvC,OAEE,oBAAC,cAAD;QAAwD,MAAM,IAAI;QAC/D,UAAA,IAAI;OACO,GAFK,GAAG,IAAI,MAAM,GAAG,IAAI,KAAK,GAAG,OAEjC;MAElB,CAAC;KACS,CAAA;IACV,EAAA,GAjCK,IAAI,GAiCT;GAER,CAAC,EACI,CAAA,CACF;;CACJ,CAAA;AAET"}
@@ -1,6 +1,6 @@
1
1
  import { cn } from "./classNames-BzrkDnOD.js";
2
- import { useArgoDesign } from "./context-D7X470dy.js";
3
- import { Check, ChevronRight, Circle, Loader2, ToggleRight } from "./icons-Cek151jC.js";
2
+ import { useArgoDesign } from "./context-U293r3v-.js";
3
+ import { Check, ChevronRight, Circle, Loader2, ToggleRight } from "./icons-wcA70iQx.js";
4
4
  import { ScrollArea } from "./internal/components/ScrollArea.js";
5
5
  import { Root, Slottable } from "@radix-ui/react-slot";
6
6
  import { createContext, use, useMemo } from "react";
@@ -329,4 +329,4 @@ DropdownMenu.ItemDescription = DropdownMenuItemDescription;
329
329
  //#endregion
330
330
  export { DropdownMenu };
331
331
 
332
- //# sourceMappingURL=DropdownMenu-CgVwhDvl.js.map
332
+ //# sourceMappingURL=DropdownMenu-gRM-A8qU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownMenu-gRM-A8qU.js","names":["Root"],"sources":["../src/components/DropdownMenu/DropdownMenuItemIndicator.tsx","../src/components/DropdownMenu/ItemIcon.tsx","../src/components/DropdownMenu/styles.ts","../src/components/DropdownMenu/DropdownMenuCheckboxItem.tsx","../src/components/DropdownMenu/DropdownMenuContext.tsx","../src/components/DropdownMenu/DropdownMenuContent.tsx","../src/components/DropdownMenu/DropdownMenuItem.tsx","../src/components/DropdownMenu/DropdownMenuItemDescription.tsx","../src/components/DropdownMenu/DropdownMenuLabel.tsx","../src/components/DropdownMenu/DropdownMenuRadioGroup/DropdownMenuRadioGroup.tsx","../src/components/DropdownMenu/DropdownMenuRadioGroup/DropdownMenuRadioItem.tsx","../src/components/DropdownMenu/DropdownMenuSeparator.tsx","../src/components/DropdownMenu/DropdownMenuSub/DropdownMenuSub.tsx","../src/components/DropdownMenu/DropdownMenuSub/DropdownMenuSubContent.tsx","../src/components/DropdownMenu/DropdownMenuSub/DropdownMenuSubTrigger.tsx","../src/components/DropdownMenu/DropdownMenuTrigger.tsx","../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import type { ComponentProps } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport type { VariantProps } from 'class-variance-authority';\nimport { cva } from 'class-variance-authority';\n\nimport { Check, Circle, ToggleRight } from '../../icons';\n\nconst variants = cva(\n [\n 'tailwindcss-preflight',\n 'tw:pointer-events-none',\n\n // sizing\n 'tw:size-4',\n 'tw:aspect-square',\n 'tw:shrink-0',\n\n // layout\n 'tw:flex',\n 'tw:items-center',\n 'tw:justify-center',\n ],\n {\n variants: {\n variant: {\n none: [],\n radio: [\n 'tw:border',\n 'tw:border-solid',\n 'tw:border-border',\n 'tw:rounded-full',\n 'tw:group-data-[variant=default]/dropdown-menu-content:bg-input-background',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:bg-background',\n\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-2',\n 'tw:data-[state=unchecked]:[&_svg]:hidden',\n // Lucide Circle is stroke-only — force fill to match the stroke\n // (currentColor) so the indicator reads as a solid dot.\n 'tw:[&_svg]:fill-current',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:[&_svg]:text-primary',\n 'tw:group-data-[variant=default]/dropdown-menu-content:[&_svg]:text-primary',\n ],\n check: ['tw:[&_svg:not([class*=\"tw:size-\"])]:size-3.5', 'tw:[&_svg]:text-primary'],\n checkbox: [\n 'tw:[&_svg]:text-primary-foreground',\n 'tw:border',\n 'tw:border-solid',\n 'tw:rounded',\n 'tw:group-data-[variant=default]/dropdown-menu-content:border-input',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:border-input',\n\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-3',\n 'tw:data-[state=unchecked]:[&_svg]:hidden',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:data-[state=checked]:border-primary',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:data-[state=checked]:bg-primary',\n 'tw:group-data-[variant=default]/dropdown-menu-content:data-[state=checked]:border-primary',\n 'tw:group-data-[variant=default]/dropdown-menu-content:data-[state=checked]:bg-primary',\n ],\n switch: [\n 'tw:size-5',\n // Lucide SVGs default to 24×24 — constrain the rendered ToggleRight\n // to the indicator slot so it doesn't overflow.\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-5',\n 'tw:text-muted-foreground',\n 'tw:data-[state=unchecked]:rotate-180',\n 'tw:group-data-[variant=default]/dropdown-menu-content:data-[state=checked]:text-primary',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:data-[state=checked]:text-primary',\n ],\n },\n },\n },\n);\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.ItemIndicator> &\n VariantProps<typeof variants>;\n\nexport const DropdownMenuItemIndicator = ({\n variant,\n className,\n forceMount: forceMountProp,\n ...rest\n}: Props) => {\n const IconComp = (() => {\n if (variant === 'switch') return ToggleRight;\n if (variant === 'radio') return Circle;\n return Check;\n })();\n\n const forceMount = (() => {\n if (forceMountProp) return true;\n // All variants, except for check, require rendering at all times.\n return variant === 'check' ? undefined : true;\n })();\n\n if (variant === 'none') return null;\n\n return (\n <DropdownMenuPrimitive.ItemIndicator\n {...rest}\n forceMount={forceMount}\n className={variants({ variant, className })}\n >\n <IconComp />\n </DropdownMenuPrimitive.ItemIndicator>\n );\n};\n","import type { ComponentProps, ReactNode } from 'react';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<'span'> & {\n children: ReactNode;\n};\n\nexport const ItemIcon = ({ className, children, ...props }: Props) => (\n <span\n {...props}\n className={cn(\n 'tw:inline-flex',\n 'tw:items-center',\n 'tw:justify-center',\n 'tw:aspect-square',\n // 20px container fits the 16px Lucide glyph plus 2px breathing room\n // each side — the previous tw:size-4 + tw:p-0.5 clipped the 16px child.\n 'tw:size-5',\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-4',\n 'tw:group-data-[variant=default]/dropdown-menu-content:text-muted-foreground',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:text-primary',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:group-aria-disabled:text-muted-foreground',\n 'tw:group-data-[variant=default]/dropdown-menu-content:group-hover:text-primary',\n className,\n )}\n >\n {children}\n </span>\n);\n","import { cn } from '../../utils';\n\nexport const itemVariants = cn(\n // reset\n 'tailwindcss-preflight',\n 'tw:outline-hidden',\n 'tw:group',\n 'tw:peer',\n 'tw:relative',\n\n // positioning\n 'tw:flex',\n 'tw:flex-1',\n 'tw:items-center',\n 'tw:gap-2',\n\n // An icon passed as `children` rather than via the `icon` prop misses `ItemIcon`,\n // so without this it falls back to Lucide's 24px default and towers over the\n // siblings this row is laid out for. The `:not()` keeps a call-site size winning.\n 'tw:[&_svg:not([class*=\"tw:size-\"])]:size-4',\n\n 'tw:cursor-pointer',\n 'tw:select-none',\n 'tw:transition-colors',\n\n // spacing\n 'tw:p-2',\n\n // typography\n 'tw:font-sans',\n 'tw:text-sm',\n\n 'tw:aria-disabled:pointer-events-none',\n 'tw:aria-disabled:opacity-50',\n\n 'tw:focus-visible:outline-hidden',\n\n 'tw:group-data-[variant=default]/dropdown-menu-content:rounded',\n 'tw:group-data-[variant=default]/dropdown-menu-content:focus:bg-muted',\n 'tw:group-data-[variant=default]/dropdown-menu-content:focus:text-foreground',\n 'tw:group-data-[variant=default]/dropdown-menu-content:hover:bg-muted',\n 'tw:group-data-[variant=default]/dropdown-menu-content:hover:text-foreground',\n\n 'tw:group-data-[variant=argo]/dropdown-menu-content:rounded-md',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:text-popover-foreground',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:focus:text-primary',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:focus:bg-primary/10',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:hover:text-primary',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:hover:bg-primary/10',\n);\n\nexport const contentVariants = cn(\n 'tailwindcss-preflight',\n 'tw:group/dropdown-menu-content',\n // Sit above Modal/Sheet (z-1051), matching the other floating overlays (Popover/Select z-1055)\n 'tw:z-[1055]',\n\n // positioning\n 'tw:flex',\n 'tw:flex-col',\n 'tw:origin-(--radix-dropdown-menu-content-transform-origin)',\n\n // sizing\n 'tw:max-h-[var(--radix-dropdown-menu-content-available-height)]',\n 'tw:min-w-32',\n\n // border\n 'tw:border',\n 'tw:border-border',\n 'tw:shadow-md',\n\n // surface — semantic tokens, so a portalled menu follows the brand and the scheme\n 'tw:bg-popover',\n 'tw:text-popover-foreground',\n\n // Radius is the only thing the surface variants differ in.\n 'tw:data-[variant=default]:rounded-md',\n 'tw:data-[variant=argo]:rounded-2xl',\n\n // animations\n 'tw:data-[state=open]:animate-in',\n 'tw:data-[state=open]:fade-in-0',\n 'tw:data-[state=open]:zoom-in-95',\n\n 'tw:data-[state=closed]:animate-out',\n 'tw:data-[state=closed]:fade-out-0',\n 'tw:data-[state=closed]:zoom-out-95',\n\n 'tw:data-[side=bottom]:slide-in-from-top-2',\n 'tw:data-[side=left]:slide-in-from-right-2',\n 'tw:data-[side=right]:slide-in-from-left-2',\n 'tw:data-[side=top]:slide-in-from-bottom-2',\n);\n","import type { ComponentProps, ReactNode } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { Loader2 } from '../../icons';\nimport { cn } from '../../utils';\n\nimport { DropdownMenuItemIndicator } from './DropdownMenuItemIndicator';\nimport { ItemIcon } from './ItemIcon';\nimport { itemVariants } from './styles';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem> & {\n closeOnSelect?: boolean;\n indicator?: 'switch' | 'checkbox' | 'check';\n indicatorAlign?: 'start' | 'end';\n isLoading?: boolean;\n /** Leading Lucide icon, drawn like `DropdownMenu.Item`'s so mixed menus line up. */\n icon?: ReactNode;\n};\n\nexport const DropdownMenuCheckboxItem = ({\n className,\n children,\n checked,\n closeOnSelect = false,\n onSelect,\n indicatorAlign = 'start',\n indicator = 'checkbox',\n isLoading = false,\n icon,\n ...props\n}: Props) => {\n const isAtStart = indicatorAlign === 'start';\n const indicatorEle = isLoading ? (\n <ItemIcon className={isAtStart ? '' : 'tw:ml-auto'}>\n <Loader2 className=\"tw:animate-spin\" />\n </ItemIcon>\n ) : (\n <DropdownMenuItemIndicator variant={indicator} className={isAtStart ? '' : 'tw:ml-auto'} />\n );\n\n const handleSelect = (event: Event) => {\n if (!closeOnSelect) event.preventDefault();\n onSelect?.(event);\n };\n\n return (\n <DropdownMenuPrimitive.CheckboxItem\n className={cn(itemVariants, className)}\n checked={checked}\n onSelect={handleSelect}\n {...props}\n >\n {isAtStart && indicatorEle}\n {icon && <ItemIcon>{icon}</ItemIcon>}\n {children}\n {!isAtStart && indicatorEle}\n </DropdownMenuPrimitive.CheckboxItem>\n );\n};\n","import { createContext, use } from 'react';\n\nexport type DropdownMenuVariant = 'default' | 'argo';\n\ntype DropdownMenuContextType = {\n variant: DropdownMenuVariant;\n};\n\nexport const DropdownMenuContext = createContext<DropdownMenuContextType>({\n variant: 'default',\n});\n\nexport const useDropdownMenuContext = () => use(DropdownMenuContext);\n","import type { ComponentProps } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { cn } from '../../utils';\nimport { ScrollArea } from '../ScrollArea';\n\nimport { useDropdownMenuContext } from './DropdownMenuContext';\nimport { contentVariants } from './styles';\n\ntype Props = Omit<\n ComponentProps<typeof DropdownMenuPrimitive.Content>,\n 'forceMount' | 'asChild'\n> & {\n forceMount?: boolean;\n /** Classes for the inner scroll area, not the popup. Set a width, not a `max-width` (clips rows). */\n className?: string;\n viewPortClassName?: string;\n container?: HTMLElement | null;\n};\n\nexport const DropdownMenuContent = ({\n className,\n sideOffset = 4,\n forceMount,\n children,\n viewPortClassName,\n container,\n ...props\n}: Props) => {\n const { variant } = useDropdownMenuContext();\n\n return (\n <DropdownMenuPrimitive.Portal forceMount={forceMount || undefined} container={container}>\n <DropdownMenuPrimitive.Content\n {...props}\n data-variant={variant}\n sideOffset={sideOffset}\n className={contentVariants}\n >\n <ScrollArea\n className={className}\n viewPortClassName={cn(\n 'tw:p-2',\n 'tw:max-h-[var(--radix-dropdown-menu-content-available-height)]',\n viewPortClassName,\n )}\n scrollBarClassName=\"tw:w-1.5\"\n >\n {children}\n </ScrollArea>\n </DropdownMenuPrimitive.Content>\n </DropdownMenuPrimitive.Portal>\n );\n};\n","import type { ComponentProps, PointerEventHandler, ReactNode } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\nimport { Root, Slottable } from '@radix-ui/react-slot';\n\nimport { Loader2 } from '../../icons';\nimport { cn } from '../../utils';\n\nimport { ItemIcon } from './ItemIcon';\nimport { itemVariants } from './styles';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.Item> & {\n /**\n * Stops the closing item stealing focus from the modal it opens (breaks `autoFocus`).\n * https://github.com/radix-ui/primitives/issues/2193#issuecomment-2758461323\n */\n asModalTrigger?: boolean;\n /** Leading Lucide icon. */\n icon?: ReactNode;\n isLoading?: boolean;\n iconClassName?: string;\n};\n\nexport const DropdownMenuItem = ({\n ref,\n className,\n asModalTrigger = false,\n onSelect,\n onPointerLeave,\n onPointerMove,\n children,\n asChild,\n icon,\n iconClassName,\n isLoading = false,\n ...props\n}: Props) => {\n const Comp = asChild ? Root : 'div';\n const adornment = isLoading ? <Loader2 className=\"tw:animate-spin\" /> : icon;\n\n const handleOnSelect = (event: Event) => {\n // keeps the menu open so the modal is not unmounted\n if (asModalTrigger) event.preventDefault();\n onSelect?.(event);\n };\n\n const handlePointerLeave: PointerEventHandler<HTMLDivElement> = (event) => {\n // prevents focus stealing from modal\n if (asModalTrigger) event.preventDefault();\n onPointerLeave?.(event);\n };\n\n const handlePointerMove: PointerEventHandler<HTMLDivElement> = (event) => {\n // prevents focus stealing from modal\n if (asModalTrigger) event.preventDefault();\n onPointerMove?.(event);\n };\n\n return (\n <DropdownMenuPrimitive.Item\n {...props}\n ref={ref}\n onSelect={handleOnSelect}\n onPointerLeave={handlePointerLeave}\n onPointerMove={handlePointerMove}\n className={cn(itemVariants, asChild && 'tw:text-inherit', className)}\n asChild\n >\n <Comp>\n {adornment && <ItemIcon className={iconClassName}>{adornment}</ItemIcon>}\n <Slottable>{children}</Slottable>\n </Comp>\n </DropdownMenuPrimitive.Item>\n );\n};\n","import type { ComponentProps } from 'react';\nimport { cva } from 'class-variance-authority';\n\nimport { cn } from '../../utils';\n\nconst descriptionVariants = cva(\n [\n 'tw:box-border',\n 'tw:ml-auto',\n 'tw:font-sans',\n 'tw:tracking-normal',\n 'tw:font-normal',\n 'tw:text-xs',\n 'tw:text-muted-foreground',\n ],\n {\n variants: {\n hideOnHover: {\n true: ['tw:group-focus-within:hidden', 'tw:group-hover:hidden'],\n false: [],\n },\n },\n defaultVariants: {},\n },\n);\n\ntype Props = ComponentProps<'span'> & {\n hideOnHover?: boolean;\n};\n\nexport const DropdownMenuItemDescription = ({\n className,\n children,\n hideOnHover = false,\n ...props\n}: Props) => {\n return (\n <span {...props} className={cn(descriptionVariants({ hideOnHover }), className)}>\n {children}\n </span>\n );\n};\n","import type { ComponentProps } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.Label>;\n\nexport const DropdownMenuLabel = ({ className, ...props }: Props) => {\n return (\n <DropdownMenuPrimitive.Label\n className={cn(\n 'tw:p-2',\n 'tw:font-medium',\n 'tw:text-xs',\n 'tw:text-muted-foreground',\n className,\n )}\n {...props}\n />\n );\n};\n","import type { ComponentProps } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\ntype Props<Value> = Omit<\n ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>,\n 'value' | 'onValueChange' | 'defaultValue'\n> & {\n value?: Value;\n defaultValue?: Value;\n onValueChange?: (value: Value) => void;\n};\n\nexport const DropdownMenuRadioGroup = <Value extends string = string>({\n value,\n defaultValue,\n onValueChange,\n ...props\n}: Props<Value>) => {\n const handleChange = (value: string) => {\n onValueChange?.(value as Value);\n };\n\n return (\n <DropdownMenuPrimitive.RadioGroup\n {...props}\n value={value}\n defaultValue={defaultValue}\n onValueChange={handleChange}\n />\n );\n};\n","import type { ComponentProps, ReactNode } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { Loader2 } from '../../../icons';\nimport { cn } from '../../../utils';\nimport { DropdownMenuItemIndicator } from '../DropdownMenuItemIndicator';\nimport { ItemIcon } from '../ItemIcon';\nimport { itemVariants } from '../styles';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.RadioItem> & {\n closeOnSelect?: boolean;\n indicatorAlign?: 'start' | 'end';\n indicator?: 'radio' | 'check' | 'none';\n icon?: ReactNode;\n iconClassName?: string;\n isLoading?: boolean;\n};\n\nexport const DropdownMenuRadioItem = ({\n className,\n children,\n closeOnSelect,\n onSelect,\n indicatorAlign = 'start',\n indicator = 'radio',\n icon,\n iconClassName,\n isLoading = false,\n ...props\n}: Props) => {\n const isAtStart = indicatorAlign === 'start';\n const indicatorEle = isLoading ? (\n <ItemIcon className={iconClassName}>\n <Loader2 className=\"tw:animate-spin\" />\n </ItemIcon>\n ) : (\n <DropdownMenuItemIndicator variant={indicator} />\n );\n\n const handleSelect = (event: Event) => {\n if (!closeOnSelect) event.preventDefault();\n onSelect?.(event);\n };\n\n return (\n <DropdownMenuPrimitive.RadioItem\n className={cn(\n itemVariants,\n 'tw:data-[state=checked]:cursor-default',\n {\n 'tw:data-[state=checked]:bg-neutral-100': indicator === 'none',\n // Semantic tint so it flips under `[data-theme='dark']`.\n 'tw:group-data-[variant=argo]/dropdown-menu-content:data-[state=checked]:bg-primary/10':\n indicator === 'check',\n },\n className,\n )}\n onSelect={handleSelect}\n {...props}\n >\n {isAtStart && indicatorEle}\n {icon && <ItemIcon className={iconClassName}>{icon}</ItemIcon>}\n <span className=\"tw:flex tw:min-w-0 tw:flex-1 tw:items-center tw:gap-2\">{children}</span>\n {!isAtStart && indicatorEle}\n </DropdownMenuPrimitive.RadioItem>\n );\n};\n","import type { ComponentProps } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.Separator>;\n\nexport const DropdownMenuSeparator = ({ className, ...props }: Props) => (\n <DropdownMenuPrimitive.Separator\n className={cn(\n 'tw:relative',\n 'tw:z-10',\n\n // layout\n 'tw:flex',\n 'tw:items-center',\n 'tw:justify-center',\n 'tw:w-full',\n\n // separator line\n 'tw:before:content-[\"\"]',\n 'tw:before:w-full',\n 'tw:before:h-px',\n\n 'tw:group-data-[variant=default]/dropdown-menu-content:py-2',\n 'tw:group-data-[variant=default]/dropdown-menu-content:before:bg-border',\n\n 'tw:group-data-[variant=argo]/dropdown-menu-content:py-1',\n 'tw:group-data-[variant=argo]/dropdown-menu-content:before:bg-border',\n\n className,\n )}\n {...props}\n />\n);\n","import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nexport const DropdownMenuSub = DropdownMenuPrimitive.Sub;\n","import type { ComponentProps } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { cn } from '../../../utils';\nimport { useDropdownMenuContext } from '../DropdownMenuContext';\nimport { contentVariants } from '../styles';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.SubContent>;\n\nexport const DropdownMenuSubContent = ({ className, ...props }: Props) => {\n const { variant } = useDropdownMenuContext();\n return (\n <DropdownMenuPrimitive.Portal>\n <DropdownMenuPrimitive.SubContent\n data-variant={variant}\n className={cn(contentVariants, 'tw:z-[1041]', 'tw:p-2', className)}\n {...props}\n />\n </DropdownMenuPrimitive.Portal>\n );\n};\n","import type { ComponentProps, ReactNode } from 'react';\nimport * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';\n\nimport { ChevronRight } from '../../../icons';\nimport { cn } from '../../../utils';\nimport { ItemIcon } from '../ItemIcon';\nimport { itemVariants } from '../styles';\n\ntype Props = ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {\n /** Leading Lucide icon, drawn like `DropdownMenu.Item`'s so the trigger lines up with items. */\n icon?: ReactNode;\n};\n\nexport const DropdownMenuSubTrigger = ({ className, children, icon, ...props }: Props) => {\n return (\n <DropdownMenuPrimitive.SubTrigger className={cn(itemVariants, className)} {...props}>\n {icon && <ItemIcon>{icon}</ItemIcon>}\n {children}\n <ChevronRight className=\"tw:ml-auto tw:size-5\" />\n </DropdownMenuPrimitive.SubTrigger>\n );\n};\n","import type { ComponentProps } from 'react';\nimport { Trigger } from '@radix-ui/react-dropdown-menu';\n\nimport { cn } from '../../utils';\n\ntype Props = ComponentProps<typeof Trigger>;\n\nexport const DropdownMenuTrigger = ({ ref, className, ...props }: Props) => (\n <Trigger\n {...props}\n ref={ref}\n data-slot=\"dropdown-menu-trigger\"\n className={cn('tw:group/dropdown-menu-trigger', className)}\n />\n);\n","import { useMemo } from 'react';\nimport type { ComponentProps } from 'react';\nimport { Group, Root } from '@radix-ui/react-dropdown-menu';\n\nimport { useArgoDesign } from '../ThemeProvider/context';\n\nimport { DropdownMenuCheckboxItem } from './DropdownMenuCheckboxItem';\nimport { DropdownMenuContent } from './DropdownMenuContent';\nimport type { DropdownMenuVariant } from './DropdownMenuContext';\nimport { DropdownMenuContext } from './DropdownMenuContext';\nimport { DropdownMenuItem } from './DropdownMenuItem';\nimport { DropdownMenuItemDescription } from './DropdownMenuItemDescription';\nimport { DropdownMenuLabel } from './DropdownMenuLabel';\nimport { DropdownMenuRadioGroup, DropdownMenuRadioItem } from './DropdownMenuRadioGroup';\nimport { DropdownMenuSeparator } from './DropdownMenuSeparator';\nimport { DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger } from './DropdownMenuSub';\nimport { DropdownMenuTrigger } from './DropdownMenuTrigger';\n\ntype Props = ComponentProps<typeof Root>;\n\nexport const DropdownMenu = ({\n // change a default value to false, for modal property, as it is not used in most cases\n modal = false,\n ...props\n}: Props) => {\n const effectiveVariant: DropdownMenuVariant = useArgoDesign() ? 'argo' : 'default';\n const contextValue = useMemo(() => ({ variant: effectiveVariant }), [effectiveVariant]);\n\n return (\n <DropdownMenuContext value={contextValue}>\n <Root {...props} modal={modal} />\n </DropdownMenuContext>\n );\n};\n\n/**\n * Main Layout\n */\nDropdownMenu.Trigger = DropdownMenuTrigger;\nDropdownMenu.Content = DropdownMenuContent;\nDropdownMenu.Group = Group;\n\n/**\n * Sub Layout\n */\nDropdownMenu.Sub = DropdownMenuSub;\nDropdownMenu.SubContent = DropdownMenuSubContent;\nDropdownMenu.SubTrigger = DropdownMenuSubTrigger;\n\n/**\n * Items can be used either Sub ar Main Layout\n */\nDropdownMenu.Separator = DropdownMenuSeparator;\nDropdownMenu.Label = DropdownMenuLabel;\nDropdownMenu.Item = DropdownMenuItem;\nDropdownMenu.CheckboxItem = DropdownMenuCheckboxItem;\nDropdownMenu.RadioGroup = DropdownMenuRadioGroup;\nDropdownMenu.RadioItem = DropdownMenuRadioItem;\n\n// item content\nDropdownMenu.ItemDescription = DropdownMenuItemDescription;\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,WAAW,IACf;CACE;CACA;CAGA;CACA;CACA;CAGA;CACA;CACA;AACF,GACA,EACE,UAAU,EACR,SAAS;CACP,MAAM,CAAC;CACP,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EAGA;EACA;EACA;CACF;CACA,OAAO,CAAC,kDAAgD,yBAAyB;CACjF,UAA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0B,EAAE,WAAW,UAAU,MAAM,GAAG,YAAmB;CACxF,OACE,qBAAC,sBAAsB,YAAvB;EAAkC,WAAW,GAAG,cAAc,SAAS;EAAG,GAAI;EAA9E,UAAA;GACG,QAAQ,oBAAC,UAAD,EAAA,UAAW,KAAe,CAAA;GAClC;GACD,oBAAC,cAAD,EAAc,WAAU,uBAAwB,CAAA;EAChB;;AAEtC;;;ACdA,MAAa,uBAAuB,EAAE,KAAK,WAAW,GAAG,YACvD,oBAAC,SAAD;CACE,GAAI;CACC;CACL,aAAU;CACV,WAAW,GAAG,kCAAkC,SAAS;AAC1D,CAAA;;;ACOH,MAAa,gBAAgB,EAE3B,QAAQ,OACR,GAAG,YACQ;CACX,MAAM,mBAAwC,cAAc,IAAI,SAAS;CACzE,MAAM,eAAe,eAAe,EAAE,SAAS,iBAAiB,IAAI,CAAC,gBAAgB,CAAC;CAEtF,OACE,oBAAC,qBAAD;EAAqB,OAAO;EAC1B,UAAA,oBAACA,QAAD;GAAM,GAAI;GAAc;EAAQ,CAAA;CACb,CAAA;AAEzB;;;;AAKA,aAAa,UAAU;AACvB,aAAa,UAAU;AACvB,aAAa,QAAQ;;;;AAKrB,aAAa,MAAM;AACnB,aAAa,aAAa;AAC1B,aAAa,aAAa;;;;AAK1B,aAAa,YAAY;AACzB,aAAa,QAAQ;AACrB,aAAa,OAAO;AACpB,aAAa,eAAe;AAC5B,aAAa,aAAa;AAC1B,aAAa,YAAY;AAGzB,aAAa,kBAAkB"}
@@ -1,7 +1,7 @@
1
- import { Tooltip } from "./utils-BW4AE8VP.js";
2
- import { Info } from "./icons-Cek151jC.js";
1
+ import { Tooltip } from "./utils-Bd28bWgm.js";
2
+ import { Info } from "./icons-wcA70iQx.js";
3
3
  import { Label } from "./internal/components/Label.js";
4
- import { FormGroup } from "./FormGroup-DR_gZ25-.js";
4
+ import { FormGroup } from "./FormGroup-CmNiAtU6.js";
5
5
  import { useRef } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { createFormHookContexts, useStore } from "@tanstack/react-form";
@@ -10,9 +10,8 @@ const { fieldContext, useFieldContext, formContext, useFormContext } = createFor
10
10
  //#endregion
11
11
  //#region src/blocks/Form/connectors/FieldItem.tsx
12
12
  /**
13
- * Shared frame for a form field: label (+ required marker + tooltip), the control, and help/error
14
- * text. It reads the field from context and owns everything derivable — validity, the error/help
15
- * ids, and the control's `aria-*` wiring — so a connector only picks a control and binds its value.
13
+ * Shared form-field frame: label, control, help/error text. Owns validity, ids and `aria-*` wiring,
14
+ * so a connector only picks a control and binds its value.
16
15
  */
17
16
  const FieldItem = ({ label, action, required, requiredMark = "required", labelling = "for", help, tooltip, className, "aria-describedby": ariaDescribedBy, children }) => {
18
17
  const field = useFieldContext();
@@ -22,29 +21,17 @@ const FieldItem = ({ label, action, required, requiredMark = "required", labelli
22
21
  /**
23
22
  * The submit count as of this field's first render.
24
23
  *
25
- * - `submissionAttempts` never goes down, so a bare `> 0` would reveal errors on a field that mounted
26
- * *after* a failed submit — switch a type on a form that already failed Save and every freshly
27
- * revealed control says "Required" before the user reaches it.
28
- * - Comparing against the mount value asks the question that matters: has a submit happened while this
29
- * field was on screen?
30
- * - `form.reset()` puts the counter back to 0 without unmounting anything, so the baseline has to
31
- * follow it down. Left alone it outruns the counter and the next submit compares `1 > 1` — the
32
- * error stays hidden until a second one.
24
+ * - A bare `> 0` would flag fields mounted after a failed submit.
25
+ * - `form.reset()` zeroes the counter, so the baseline follows it down.
33
26
  */
34
27
  const attemptsAtMountRef = useRef(submissionAttempts);
35
28
  if (submissionAttempts < attemptsAtMountRef.current) attemptsAtMountRef.current = submissionAttempts;
36
29
  /**
37
- * ⚠️ **Blurred, not touched.**
30
+ * ⚠️ Blurred, not touched.
38
31
  *
39
- * `isTouched` looks like the right gate and is not: `FormApi.setFieldValue` sets it, so filling a field
40
- * *for* the user — an id derived from a name, a default written when a type is picked — reads as the
41
- * user having been there (`validateField` and `validateAllFields` set it too). The visible result is
42
- * "Required" under a control the user has never been near.
43
- *
44
- * `isBlurred` is per-field and only a real blur sets it: the user was in this control and left it.
45
- * A submit attempt reveals everything that was on screen for it, because a field nobody visited still
46
- * has to explain itself once the button is pressed. `setServerFieldErrors` marks `isBlurred` for the
47
- * same reason — a mutation that fails outside a submit has neither signal otherwise.
32
+ * - `setFieldValue` and `validateField` set `isTouched`, so code-filled fields would show errors.
33
+ * - Only a real blur sets `isBlurred` — and `setServerFieldErrors`, for failures outside a submit.
34
+ * - A submit attempt reveals every field that was on screen for it.
48
35
  */
49
36
  const isInvalid = (isBlurred || submissionAttempts > attemptsAtMountRef.current) && errors.length > 0;
50
37
  const errorId = `${field.name}-error`;
@@ -105,4 +92,4 @@ const FieldItem = ({ label, action, required, requiredMark = "required", labelli
105
92
  //#endregion
106
93
  export { FieldItem, fieldContext, formContext, useFieldContext, useFormContext };
107
94
 
108
- //# sourceMappingURL=FieldItem-DZGIdiXE.js.map
95
+ //# sourceMappingURL=FieldItem-2wMXQ0Qw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldItem-2wMXQ0Qw.js","names":[],"sources":["../src/blocks/Form/contexts.ts","../src/blocks/Form/connectors/FieldItem.tsx"],"sourcesContent":["import { createFormHookContexts } from '@tanstack/react-form';\n\nexport const { fieldContext, useFieldContext, formContext, useFormContext } =\n createFormHookContexts();\n","import { type ReactNode, useRef } from 'react';\nimport { useStore } from '@tanstack/react-form';\n\nimport { Label } from '../../../components/Label';\nimport { Tooltip } from '../../../components/Tooltip';\nimport { Info } from '../../../icons';\nimport { FormGroup } from '../../FormGroup';\nimport { useFieldContext, useFormContext } from '../contexts';\n\n/** The a11y wiring `FieldItem` derives for the control — spread it onto the rendered element. */\ntype FieldControlProps = {\n id: string;\n name: string;\n 'aria-required'?: true;\n 'aria-invalid'?: true;\n 'aria-describedby'?: string;\n /** Present only under `labelling: 'aria-labelledby'` — see the prop. */\n 'aria-labelledby'?: string;\n};\n\n/** Which marker sits next to the label. Purely visual — `aria-required` is driven by `required`. */\ntype RequiredMark = 'required' | 'optional' | 'hidden';\n\n/**\n * How the control takes its accessible name from the label.\n *\n * - `'for'` (default) — `<label for>` at the control's `id`; for labelable elements (`input` etc.).\n * - `'aria-labelledby'` — the label id comes back in `control['aria-labelledby']`, no `for`. For\n * non-labelable controls (CodeMirror, Lexical, `div[role]`), which `<label for>` never names.\n */\ntype Labelling = 'for' | 'aria-labelledby';\n\ntype Props = {\n label?: ReactNode;\n /** Trailing node on the label row (e.g. a `Link`); not part of the accessible name. */\n action?: ReactNode;\n required?: boolean;\n /**\n * Gated by `required`: `'required'` shows `*` only if required, `'optional'` shows `(optional)`\n * only if not, `'hidden'` neither. Defaults to `'required'`.\n */\n requiredMark?: RequiredMark;\n /** See {@link Labelling}. Defaults to `'for'`. */\n labelling?: Labelling;\n help?: ReactNode;\n tooltip?: ReactNode;\n className?: string;\n 'aria-describedby'?: string;\n children: (control: FieldControlProps) => ReactNode;\n};\n\n/**\n * The frame props a connector re-exposes to its callers.\n *\n * - No `labelling`: the connector picks it from what its control is.\n * - Left in, it would fall into the rest spread and reach the DOM `<input>`.\n */\nexport type FieldItemProps = Omit<Props, 'children' | 'labelling'>;\n\n/**\n * Shared form-field frame: label, control, help/error text. Owns validity, ids and `aria-*` wiring,\n * so a connector only picks a control and binds its value.\n */\nexport const FieldItem = ({\n label,\n action,\n required,\n requiredMark = 'required',\n labelling = 'for',\n help,\n tooltip,\n className,\n 'aria-describedby': ariaDescribedBy,\n children,\n}: Props) => {\n const field = useFieldContext();\n const form = useFormContext();\n const { errors, isBlurred } = field.state.meta;\n const submissionAttempts = useStore(form.store, (state) => state.submissionAttempts);\n\n /**\n * The submit count as of this field's first render.\n *\n * - A bare `> 0` would flag fields mounted after a failed submit.\n * - `form.reset()` zeroes the counter, so the baseline follows it down.\n */\n const attemptsAtMountRef = useRef(submissionAttempts);\n if (submissionAttempts < attemptsAtMountRef.current)\n attemptsAtMountRef.current = submissionAttempts;\n\n /**\n * ⚠️ Blurred, not touched.\n *\n * - `setFieldValue` and `validateField` set `isTouched`, so code-filled fields would show errors.\n * - Only a real blur sets `isBlurred` — and `setServerFieldErrors`, for failures outside a submit.\n * - A submit attempt reveals every field that was on screen for it.\n */\n const isInvalid =\n (isBlurred || submissionAttempts > attemptsAtMountRef.current) && errors.length > 0;\n\n const errorId = `${field.name}-error`;\n const descriptionId = `${field.name}-description`;\n const labelId = `${field.name}-label`;\n const namesByAria = labelling === 'aria-labelledby';\n // Help and error can both apply; `undefined` when empty so the attr is omitted.\n const describedBy =\n [ariaDescribedBy, !!help && descriptionId, isInvalid && errorId].filter(Boolean).join(' ') ||\n undefined;\n\n return (\n <FormGroup className={className}>\n {(label || action) && (\n <div className=\"tw:flex tw:items-center tw:justify-between tw:gap-2\">\n <div className=\"tw:flex tw:items-center tw:gap-1\">\n {/* Marker binds to the label text; the interactive tooltip button is a sibling. */}\n {label && (\n // `htmlFor` only for labelable controls — see `Labelling`.\n <Label\n htmlFor={namesByAria ? undefined : field.name}\n id={namesByAria ? labelId : undefined}\n >\n {label}\n {requiredMark === 'required' && required && <Label.Required />}\n {requiredMark === 'optional' && !required && <Label.Optional />}\n </Label>\n )}\n\n {tooltip && (\n <Tooltip tooltip={tooltip} placement=\"top\" triggerAsChild>\n <button\n type=\"button\"\n aria-label={\n typeof label === 'string'\n ? `More information about ${label}`\n : 'More information'\n }\n className=\"tw:text-muted-foreground tw:focus:outline-hidden tw:focus-visible:text-primary tailwindcss-preflight\"\n >\n <Info className=\"tw:size-3\" />\n </button>\n </Tooltip>\n )}\n </div>\n\n {action}\n </div>\n )}\n\n {children({\n id: field.name,\n name: field.name,\n 'aria-required': required || undefined,\n 'aria-invalid': isInvalid || undefined,\n 'aria-describedby': describedBy,\n 'aria-labelledby': namesByAria && label ? labelId : undefined,\n })}\n\n {(help || isInvalid) && (\n <div>\n {help && <FormGroup.Help id={descriptionId}>{help}</FormGroup.Help>}\n {isInvalid && <FormGroup.Error id={errorId} errors={errors} />}\n </div>\n )}\n </FormGro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