@middag-io/react 0.44.1 → 0.45.2

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 (362) hide show
  1. package/README.md +7 -0
  2. package/dist-lib/{FormField-Bj43PjHH.js → FormField-Csx8hGAW.js} +1956 -1936
  3. package/dist-lib/{FormPanelBlock-C6eDfGoI.js → FormPanelBlock-Bmd0DpiX.js} +337 -337
  4. package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
  5. package/dist-lib/base/blocks/LinkListBlock.d.ts +2 -1
  6. package/dist-lib/base/blocks/LinkListBlock.d.ts.map +1 -1
  7. package/dist-lib/base/form/FormField.d.ts.map +1 -1
  8. package/dist-lib/base/layout/DashboardLayout.d.ts.map +1 -1
  9. package/dist-lib/base/partials/ConfirmationDialog/index.d.ts.map +1 -1
  10. package/dist-lib/base/partials/DataTable/cell-renderers.d.ts +1 -1
  11. package/dist-lib/base/partials/DataTable/cell-renderers.d.ts.map +1 -1
  12. package/dist-lib/base/partials/DataTable/index.d.ts +1 -1
  13. package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
  14. package/dist-lib/base/partials/DataTable/sanitize-html.d.ts +17 -0
  15. package/dist-lib/base/partials/DataTable/sanitize-html.d.ts.map +1 -0
  16. package/dist-lib/base/partials/DataTable/types.d.ts +15 -0
  17. package/dist-lib/base/partials/DataTable/types.d.ts.map +1 -1
  18. package/dist-lib/base/partials/FilterBar/index.d.ts.map +1 -1
  19. package/dist-lib/base/shell/BasicShell.js +1 -1
  20. package/dist-lib/base/shell/partials/InlineEditablePanel.js +38 -24
  21. package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
  22. package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
  23. package/dist-lib/chunks/subpath-Bh1MAmBT.js +165 -0
  24. package/dist-lib/chunks/{subpath-AeMdleNB.js → subpath-fEhy6n_U.js} +10 -6
  25. package/dist-lib/contracts/block-data/data-display.d.ts +51 -2
  26. package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
  27. package/dist-lib/contracts/generated/contract-schema.d.ts +1 -1
  28. package/dist-lib/contracts/generated/contract-types.d.ts +4 -2
  29. package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
  30. package/dist-lib/contracts/generated/index.d.ts +1 -1
  31. package/dist-lib/i18n/I18nProvider.js +1 -1
  32. package/dist-lib/i18n/instance.js +1 -1
  33. package/dist-lib/i18n/locales/en/ui.json +5 -3
  34. package/dist-lib/i18n/locales/pt-BR/ui.json +5 -3
  35. package/dist-lib/i18n/register-strings.js +1 -1
  36. package/dist-lib/index.d.ts +1 -1
  37. package/dist-lib/index.d.ts.map +1 -1
  38. package/dist-lib/middag-react.css +1 -1
  39. package/dist-lib/middag-react.js +18641 -13317
  40. package/dist-lib/primitives/reui/chart.d.ts.map +1 -1
  41. package/dist-lib/primitives/reui/chart.js +35 -31
  42. package/docs/public/schemas/ai-contract-manifest.json +1820 -0
  43. package/docs/public/schemas/blocks.json +445 -0
  44. package/docs/public/schemas/components.json +166 -0
  45. package/docs/public/schemas/connectors.json +97 -0
  46. package/docs/public/schemas/fragment.json +2329 -0
  47. package/docs/public/schemas/manifest.json +119 -0
  48. package/docs/public/schemas/navigation.json +72 -0
  49. package/docs/public/schemas/page-contract.json +2329 -0
  50. package/docs/public/schemas/shared-props.json +118 -0
  51. package/docs/public/schemas/theme-defaults.json +253 -0
  52. package/docs/public/schemas/theme.json +401 -0
  53. package/package.json +109 -3
  54. package/src/assets/lottie/calendar/schedule-1.json +1 -0
  55. package/src/assets/lottie/calendar/schedule-2.json +1 -0
  56. package/src/assets/lottie/celebration/confetti-1.json +1 -0
  57. package/src/assets/lottie/celebration/confetti-2.json +1 -0
  58. package/src/assets/lottie/celebration/confetti-3.json +1 -0
  59. package/src/assets/lottie/cloud/cloud-1.json +1 -0
  60. package/src/assets/lottie/cloud/cloud-2.json +1 -0
  61. package/src/assets/lottie/connection/network-1.json +1 -0
  62. package/src/assets/lottie/connection/network-2.json +1 -0
  63. package/src/assets/lottie/connection/network-3.json +1 -0
  64. package/src/assets/lottie/dashboard/analytics-1.json +1 -0
  65. package/src/assets/lottie/dashboard/analytics-2.json +1 -0
  66. package/src/assets/lottie/dashboard/analytics-3.json +1 -0
  67. package/src/assets/lottie/email/mail-1.json +1 -0
  68. package/src/assets/lottie/email/mail-2.json +1 -0
  69. package/src/assets/lottie/email/mail-3.json +1 -0
  70. package/src/assets/lottie/empty-state/empty-1.json +1 -0
  71. package/src/assets/lottie/empty-state/empty-2.json +1 -0
  72. package/src/assets/lottie/empty-state/empty-3.json +1 -0
  73. package/src/assets/lottie/error/warning-1.json +1 -0
  74. package/src/assets/lottie/error/warning-2.json +1 -0
  75. package/src/assets/lottie/error/warning-3.json +1 -0
  76. package/src/assets/lottie/index.ts +49 -0
  77. package/src/assets/lottie/loading/spinner-1.json +1 -0
  78. package/src/assets/lottie/loading/spinner-2.json +1 -0
  79. package/src/assets/lottie/loading/spinner-3.json +1 -0
  80. package/src/assets/lottie/maintenance/construction-1.json +1 -0
  81. package/src/assets/lottie/maintenance/construction-2.json +1 -0
  82. package/src/assets/lottie/maintenance/construction-3.json +1 -0
  83. package/src/assets/lottie/not-found/404-1.json +1 -0
  84. package/src/assets/lottie/not-found/404-2.json +1 -0
  85. package/src/assets/lottie/not-found/404-3.json +1 -0
  86. package/src/assets/lottie/notification/bell-1.json +1 -0
  87. package/src/assets/lottie/notification/bell-2.json +1 -0
  88. package/src/assets/lottie/notification/bell-3.json +1 -0
  89. package/src/assets/lottie/onboarding/welcome-1.json +1 -0
  90. package/src/assets/lottie/onboarding/welcome-2.json +1 -0
  91. package/src/assets/lottie/onboarding/welcome-3.json +1 -0
  92. package/src/assets/lottie/payment/wallet-1.json +1 -0
  93. package/src/assets/lottie/payment/wallet-2.json +1 -0
  94. package/src/assets/lottie/payment/wallet-3.json +1 -0
  95. package/src/assets/lottie/search/search-1.json +1 -0
  96. package/src/assets/lottie/search/search-2.json +1 -0
  97. package/src/assets/lottie/search/search-3.json +1 -0
  98. package/src/assets/lottie/security/lock-1.json +1 -0
  99. package/src/assets/lottie/security/lock-2.json +1 -0
  100. package/src/assets/lottie/security/lock-3.json +1 -0
  101. package/src/assets/lottie/settings/gear-1.json +1 -0
  102. package/src/assets/lottie/settings/gear-2.json +1 -0
  103. package/src/assets/lottie/settings/gear-3.json +1 -0
  104. package/src/assets/lottie/success/check-1.json +1 -0
  105. package/src/assets/lottie/success/check-2.json +1 -0
  106. package/src/assets/lottie/success/check-3.json +1 -0
  107. package/src/assets/lottie/upload/upload-1.json +1 -0
  108. package/src/assets/lottie/upload/upload-2.json +1 -0
  109. package/src/assets/lottie/upload/upload-3.json +1 -0
  110. package/src/assets/lottie/user/profile-1.json +1 -0
  111. package/src/assets/lottie/user/profile-2.json +1 -0
  112. package/src/assets/lottie/user/profile-3.json +1 -0
  113. package/src/base/blocks/ActionGridBlock.tsx +151 -0
  114. package/src/base/blocks/ActivityTimelineBlock.tsx +180 -0
  115. package/src/base/blocks/CardGridBlock.tsx +384 -0
  116. package/src/base/blocks/ChartBlock.tsx +81 -0
  117. package/src/base/blocks/DenseTableBlock.tsx +403 -0
  118. package/src/base/blocks/DetailPanelBlock.tsx +189 -0
  119. package/src/base/blocks/EmptyStateBlock.tsx +46 -0
  120. package/src/base/blocks/FormPanelBlock.lazy.tsx +38 -0
  121. package/src/base/blocks/FormPanelBlock.tsx +480 -0
  122. package/src/base/blocks/LinkListBlock.tsx +94 -0
  123. package/src/base/blocks/MarkdownPanelBlock.tsx +60 -0
  124. package/src/base/blocks/MetricCardBlock.tsx +128 -0
  125. package/src/base/blocks/StatusStripBlock.tsx +43 -0
  126. package/src/base/blocks/TabsBlock.tsx +94 -0
  127. package/src/base/form/FormField.tsx +607 -0
  128. package/src/base/form/fields/CheckboxField.tsx +56 -0
  129. package/src/base/form/fields/ColorField.tsx +76 -0
  130. package/src/base/form/fields/CurrencyField.tsx +126 -0
  131. package/src/base/form/fields/DateField.tsx +168 -0
  132. package/src/base/form/fields/DateRangeField.tsx +66 -0
  133. package/src/base/form/fields/DocumentField.tsx +222 -0
  134. package/src/base/form/fields/EntityPickerField.tsx +244 -0
  135. package/src/base/form/fields/FileUploadField.tsx +253 -0
  136. package/src/base/form/fields/MultiSelectField.tsx +286 -0
  137. package/src/base/form/fields/NativeSelectField.tsx +67 -0
  138. package/src/base/form/fields/NumberField.tsx +67 -0
  139. package/src/base/form/fields/OtpField.tsx +88 -0
  140. package/src/base/form/fields/PasswordField.tsx +69 -0
  141. package/src/base/form/fields/PhoneField.tsx +64 -0
  142. package/src/base/form/fields/RadioField.tsx +66 -0
  143. package/src/base/form/fields/RatingField.tsx +52 -0
  144. package/src/base/form/fields/SelectField.tsx +76 -0
  145. package/src/base/form/fields/SliderField.tsx +77 -0
  146. package/src/base/form/fields/SlugField.tsx +114 -0
  147. package/src/base/form/fields/StaticField.tsx +25 -0
  148. package/src/base/form/fields/SwitchField.tsx +56 -0
  149. package/src/base/form/fields/TagsField.tsx +128 -0
  150. package/src/base/form/fields/TextField.tsx +55 -0
  151. package/src/base/form/fields/TextareaField.tsx +55 -0
  152. package/src/base/form/fields/document-validation.ts +126 -0
  153. package/src/base/form/fields/field-registry.ts +53 -0
  154. package/src/base/form/fields/register-default-fields.ts +86 -0
  155. package/src/base/form/form-schema-builder.ts +192 -0
  156. package/src/base/form/form-utils.ts +71 -0
  157. package/src/base/hooks/useIsDark.ts +50 -0
  158. package/src/base/hooks/useLazyTabs.ts +98 -0
  159. package/src/base/hooks/usePolling.ts +43 -0
  160. package/src/base/hooks/useRemember.ts +58 -0
  161. package/src/base/hooks/useToast.ts +27 -0
  162. package/src/base/layout/BlockRegion.tsx +39 -0
  163. package/src/base/layout/DashboardLayout.tsx +110 -0
  164. package/src/base/layout/SidebarLayout.tsx +38 -0
  165. package/src/base/layout/StackLayout.tsx +32 -0
  166. package/src/base/layout/WizardLayout.tsx +49 -0
  167. package/src/base/partials/ActionBar/index.tsx +115 -0
  168. package/src/base/partials/ConfirmationDialog/index.tsx +128 -0
  169. package/src/base/partials/DataTable/cell-registry.ts +50 -0
  170. package/src/base/partials/DataTable/cell-renderers.tsx +372 -0
  171. package/src/base/partials/DataTable/index.tsx +1282 -0
  172. package/src/base/partials/DataTable/register-default-cells.ts +37 -0
  173. package/src/base/partials/DataTable/sanitize-html.ts +45 -0
  174. package/src/base/partials/DataTable/types.ts +229 -0
  175. package/src/base/partials/DetailSection/index.tsx +316 -0
  176. package/src/base/partials/EmptyPlaceholder/index.tsx +162 -0
  177. package/src/base/partials/EntityItem/index.tsx +154 -0
  178. package/src/base/partials/FilterBar/index.tsx +256 -0
  179. package/src/base/partials/FormSection/index.tsx +87 -0
  180. package/src/base/partials/LogViewer/JsonBlock.tsx +39 -0
  181. package/src/base/partials/LogViewer/LogEntry.tsx +68 -0
  182. package/src/base/partials/LogViewer/LogViewerToolbar.tsx +71 -0
  183. package/src/base/partials/LogViewer/index.tsx +110 -0
  184. package/src/base/partials/LogViewer/types.ts +28 -0
  185. package/src/base/partials/MarkdownContent/index.tsx +307 -0
  186. package/src/base/partials/MenuBar/index.tsx +80 -0
  187. package/src/base/partials/QuickRecordSheet/index.tsx +59 -0
  188. package/src/base/partials/ResizableSidebar/index.tsx +70 -0
  189. package/src/base/partials/StatRow/index.tsx +28 -0
  190. package/src/base/partials/StatusBar/index.tsx +126 -0
  191. package/src/base/partials/StatusIndicator/index.tsx +61 -0
  192. package/src/base/partials/StepIndicator/index.tsx +63 -0
  193. package/src/base/partials/TableOfContents/index.tsx +78 -0
  194. package/src/base/partials/TimelineList/index.tsx +273 -0
  195. package/src/base/partials/ToggleGroupControl/index.tsx +100 -0
  196. package/src/base/partials/TreeView/index.tsx +75 -0
  197. package/src/base/partials/index.ts +23 -0
  198. package/src/base/shell/AuthShell.tsx +54 -0
  199. package/src/base/shell/BasicShell.tsx +286 -0
  200. package/src/base/shell/ImmersiveShell.tsx +85 -0
  201. package/src/base/shell/partials/EditablePanelContext.tsx +82 -0
  202. package/src/base/shell/partials/EditablePanelProvider.tsx +122 -0
  203. package/src/base/shell/partials/InlineEditablePanel.tsx +239 -0
  204. package/src/base/shell/partials/InspectorContext.tsx +173 -0
  205. package/src/base/shell/partials/InspectorPanel.tsx +65 -0
  206. package/src/base/shell/partials/NavErrorBoundary.tsx +82 -0
  207. package/src/base/shell/partials/OverlayScreen.tsx +67 -0
  208. package/src/base/shell/partials/PageActionButton.tsx +203 -0
  209. package/src/base/theme/appearance.ts +133 -0
  210. package/src/base/theme/host-layout-detector.ts +119 -0
  211. package/src/base/theme/host-theme-detector.ts +146 -0
  212. package/src/base/theme/sidebar-safelist.txt +20 -0
  213. package/src/base/theme/tailwind-theme.css +136 -0
  214. package/src/base/theme/theme-bridge.css +164 -0
  215. package/src/base/theme/theme-context.tsx +142 -0
  216. package/src/base/theme/themes/classic.css +174 -0
  217. package/src/base/theme/tokens.css +290 -0
  218. package/src/base/theme/useHostTheme.ts +95 -0
  219. package/src/base/utils/clipboard.ts +39 -0
  220. package/src/base/utils/conditions.ts +27 -0
  221. package/src/base/utils/icon-registry.ts +78 -0
  222. package/src/base/utils/icons.ts +31 -0
  223. package/src/base/utils/interpolate.ts +9 -0
  224. package/src/base/utils/register-default-icons.ts +163 -0
  225. package/src/base/utils/storage.ts +65 -0
  226. package/src/base/utils/time.ts +139 -0
  227. package/src/contracts/block-data/actions.ts +73 -0
  228. package/src/contracts/block-data/data-display.ts +343 -0
  229. package/src/contracts/block-data/form.ts +164 -0
  230. package/src/contracts/block-data/index.ts +15 -0
  231. package/src/contracts/block-data/interactive.ts +34 -0
  232. package/src/contracts/block-data/shared.ts +44 -0
  233. package/src/contracts/connectors.ts +60 -0
  234. package/src/contracts/generated/contract-schema.ts +1237 -0
  235. package/src/contracts/generated/contract-types.ts +675 -0
  236. package/src/contracts/generated/index.ts +15 -0
  237. package/src/contracts/navigation.ts +59 -0
  238. package/src/contracts/page-contract-schema.ts +40 -0
  239. package/src/contracts/page-contract.ts +79 -0
  240. package/src/contracts/shared-props.ts +92 -0
  241. package/src/engine/ContractPage.tsx +178 -0
  242. package/src/engine/EntityRoutes.tsx +72 -0
  243. package/src/engine/HostSlot.tsx +126 -0
  244. package/src/engine/LazyBlock.tsx +92 -0
  245. package/src/engine/bootstrap.tsx +20 -0
  246. package/src/engine/providers/auth.tsx +87 -0
  247. package/src/engine/providers/error-reporter.tsx +89 -0
  248. package/src/engine/providers/flash.tsx +44 -0
  249. package/src/engine/providers/index.ts +18 -0
  250. package/src/engine/providers/inertia-error-reporter.tsx +61 -0
  251. package/src/engine/providers/progress.tsx +56 -0
  252. package/src/engine/providers/scope.tsx +51 -0
  253. package/src/engine/register-defaults.ts +88 -0
  254. package/src/engine/registries.ts +96 -0
  255. package/src/i18n/I18nProvider.tsx +53 -0
  256. package/src/i18n/MANIFEST.md +101 -0
  257. package/src/i18n/host-resolver.ts +18 -0
  258. package/src/i18n/instance.ts +69 -0
  259. package/src/i18n/locales/en/ui.json +277 -0
  260. package/src/i18n/locales/en/validators.json +13 -0
  261. package/src/i18n/locales/pt-BR/ui.json +277 -0
  262. package/src/i18n/locales/pt-BR/validators.json +13 -0
  263. package/src/i18n/register-strings.ts +10 -0
  264. package/src/i18n/render-label.ts +33 -0
  265. package/src/i18n/resolve-field-error.ts +29 -0
  266. package/src/i18n/useHostString.ts +50 -0
  267. package/src/i18n/useTranslation.ts +83 -0
  268. package/src/lib/actions/resolve-action-target.ts +151 -0
  269. package/src/lib/hooks/use-copy-to-clipboard.ts +37 -0
  270. package/src/lib/hooks/use-file-upload.ts +406 -0
  271. package/src/lib/hooks/use-mobile.ts +21 -0
  272. package/src/lib/host-pending.ts +76 -0
  273. package/src/lib/portal-container.ts +16 -0
  274. package/src/lib/test-ids.ts +40 -0
  275. package/src/lib/utils.ts +6 -0
  276. package/src/primitives/reui/MANIFEST.md +97 -0
  277. package/src/primitives/reui/accordion.tsx +64 -0
  278. package/src/primitives/reui/alert-dialog.tsx +196 -0
  279. package/src/primitives/reui/alert.tsx +92 -0
  280. package/src/primitives/reui/aspect-ratio.tsx +9 -0
  281. package/src/primitives/reui/autocomplete.tsx +343 -0
  282. package/src/primitives/reui/avatar.tsx +109 -0
  283. package/src/primitives/reui/badge.tsx +94 -0
  284. package/src/primitives/reui/breadcrumb.tsx +109 -0
  285. package/src/primitives/reui/button-group.tsx +83 -0
  286. package/src/primitives/reui/button.tsx +64 -0
  287. package/src/primitives/reui/calendar.tsx +220 -0
  288. package/src/primitives/reui/card.tsx +92 -0
  289. package/src/primitives/reui/carousel.tsx +239 -0
  290. package/src/primitives/reui/chart.tsx +388 -0
  291. package/src/primitives/reui/checkbox.tsx +30 -0
  292. package/src/primitives/reui/collapsible.tsx +31 -0
  293. package/src/primitives/reui/combobox.tsx +308 -0
  294. package/src/primitives/reui/command.tsx +182 -0
  295. package/src/primitives/reui/context-menu.tsx +250 -0
  296. package/src/primitives/reui/data-grid/data-grid-column-filter.tsx +172 -0
  297. package/src/primitives/reui/data-grid/data-grid-column-header.tsx +420 -0
  298. package/src/primitives/reui/data-grid/data-grid-column-visibility.tsx +51 -0
  299. package/src/primitives/reui/data-grid/data-grid-pagination.tsx +235 -0
  300. package/src/primitives/reui/data-grid/data-grid-scroll-area.tsx +427 -0
  301. package/src/primitives/reui/data-grid/data-grid-table-dnd-rows.tsx +308 -0
  302. package/src/primitives/reui/data-grid/data-grid-table-dnd.tsx +318 -0
  303. package/src/primitives/reui/data-grid/data-grid-table-virtual.tsx +491 -0
  304. package/src/primitives/reui/data-grid/data-grid-table.tsx +1430 -0
  305. package/src/primitives/reui/data-grid/data-grid.tsx +269 -0
  306. package/src/primitives/reui/data-grid-pagination.tsx +235 -0
  307. package/src/primitives/reui/date-selector.tsx +1353 -0
  308. package/src/primitives/reui/dialog.tsx +158 -0
  309. package/src/primitives/reui/drawer.tsx +133 -0
  310. package/src/primitives/reui/dropdown-menu.tsx +257 -0
  311. package/src/primitives/reui/empty.tsx +104 -0
  312. package/src/primitives/reui/field.tsx +246 -0
  313. package/src/primitives/reui/filters.tsx +1891 -0
  314. package/src/primitives/reui/frame.tsx +170 -0
  315. package/src/primitives/reui/hover-card.tsx +42 -0
  316. package/src/primitives/reui/icon-placeholder.tsx +39 -0
  317. package/src/primitives/reui/index.ts +98 -0
  318. package/src/primitives/reui/input-group.tsx +170 -0
  319. package/src/primitives/reui/input-otp.tsx +75 -0
  320. package/src/primitives/reui/input.tsx +21 -0
  321. package/src/primitives/reui/item.tsx +193 -0
  322. package/src/primitives/reui/kanban.tsx +743 -0
  323. package/src/primitives/reui/kbd.tsx +28 -0
  324. package/src/primitives/reui/label.tsx +22 -0
  325. package/src/primitives/reui/menubar.tsx +274 -0
  326. package/src/primitives/reui/native-select.tsx +62 -0
  327. package/src/primitives/reui/navigation-menu.tsx +168 -0
  328. package/src/primitives/reui/number-field.tsx +250 -0
  329. package/src/primitives/reui/pagination.tsx +127 -0
  330. package/src/primitives/reui/phone-input.tsx +231 -0
  331. package/src/primitives/reui/popover.tsx +87 -0
  332. package/src/primitives/reui/progress.tsx +31 -0
  333. package/src/primitives/reui/radio-group.tsx +43 -0
  334. package/src/primitives/reui/rating.tsx +177 -0
  335. package/src/primitives/reui/resizable.tsx +51 -0
  336. package/src/primitives/reui/scroll-area.tsx +58 -0
  337. package/src/primitives/reui/scrollspy.tsx +240 -0
  338. package/src/primitives/reui/select.tsx +188 -0
  339. package/src/primitives/reui/separator.tsx +28 -0
  340. package/src/primitives/reui/sheet.tsx +141 -0
  341. package/src/primitives/reui/sidebar.tsx +732 -0
  342. package/src/primitives/reui/skeleton.tsx +13 -0
  343. package/src/primitives/reui/slider.tsx +61 -0
  344. package/src/primitives/reui/sonner.tsx +47 -0
  345. package/src/primitives/reui/sortable.tsx +414 -0
  346. package/src/primitives/reui/spinner.tsx +16 -0
  347. package/src/primitives/reui/stepper.tsx +484 -0
  348. package/src/primitives/reui/svgs/claudeAiIcon.tsx +12 -0
  349. package/src/primitives/reui/svgs/gemini.tsx +171 -0
  350. package/src/primitives/reui/svgs/openai.tsx +9 -0
  351. package/src/primitives/reui/svgs/openaiDark.tsx +12 -0
  352. package/src/primitives/reui/switch.tsx +33 -0
  353. package/src/primitives/reui/table.tsx +114 -0
  354. package/src/primitives/reui/tabs.tsx +91 -0
  355. package/src/primitives/reui/textarea.tsx +18 -0
  356. package/src/primitives/reui/timeline.tsx +219 -0
  357. package/src/primitives/reui/toggle-group.tsx +83 -0
  358. package/src/primitives/reui/toggle.tsx +45 -0
  359. package/src/primitives/reui/tooltip.tsx +55 -0
  360. package/src/primitives/reui/tree.tsx +247 -0
  361. package/src/theme.css +71 -0
  362. package/dist-lib/chunks/subpath-q4Q2zg_p.js +0 -153
@@ -0,0 +1,162 @@
1
+ /**
2
+ * EmptyPlaceholder — contextual empty state with icon, title, description, and CTA.
3
+ *
4
+ * Variants: first-use, no-results, error, permission, compact, inline.
5
+ *
6
+ * @see NV-05-ux-blocks.md §7.1–7.8, §9.3
7
+ */
8
+
9
+ import { lazy, Suspense, type ReactElement } from "react";
10
+ import { Cancel01Icon, InboxIcon, LockIcon } from "@hugeicons/core-free-icons";
11
+ import { HugeiconsIcon } from "@hugeicons/react";
12
+ import { Link } from "@inertiajs/react";
13
+
14
+ import { getIcon } from "@/base/utils/icons";
15
+ import { cn } from "@/lib/utils";
16
+ import { Button } from "@/primitives/reui/button";
17
+
18
+ const DotLottieReact = lazy(() =>
19
+ import("@lottiefiles/dotlottie-react").then((m) => ({
20
+ default: m.DotLottieReact,
21
+ })),
22
+ );
23
+
24
+ export type EmptyPlaceholderVariant =
25
+ | "first-use"
26
+ | "no-results"
27
+ | "error"
28
+ | "permission"
29
+ | "compact"
30
+ | "inline";
31
+
32
+ export interface EmptyPlaceholderCTA {
33
+ label: string;
34
+ href?: string;
35
+ onClick?: () => void;
36
+ intent?: "primary" | "secondary";
37
+ isLoading?: boolean;
38
+ }
39
+
40
+ export interface EmptyPlaceholderProps {
41
+ variant?: EmptyPlaceholderVariant;
42
+ icon?: string;
43
+ /** Lottie JSON animation URL. Replaces the icon when provided. */
44
+ lottieUrl?: string;
45
+ title: string;
46
+ description?: string;
47
+ cta?: EmptyPlaceholderCTA;
48
+ ctaSecondary?: { label: string; href: string };
49
+ }
50
+
51
+ const VARIANT_CONFIG: Record<
52
+ EmptyPlaceholderVariant,
53
+ { iconSize: number; padding: string; maxDescWidth: string }
54
+ > = {
55
+ "first-use": {
56
+ iconSize: 56,
57
+ padding: "py-20",
58
+ maxDescWidth: "max-w-[380px]",
59
+ },
60
+ "no-results": {
61
+ iconSize: 32,
62
+ padding: "py-12",
63
+ maxDescWidth: "max-w-[360px]",
64
+ },
65
+ error: { iconSize: 48, padding: "py-16", maxDescWidth: "max-w-[400px]" },
66
+ permission: { iconSize: 48, padding: "py-16", maxDescWidth: "max-w-[400px]" },
67
+ compact: { iconSize: 48, padding: "py-10", maxDescWidth: "max-w-[360px]" },
68
+ inline: { iconSize: 32, padding: "py-6", maxDescWidth: "max-w-[320px]" },
69
+ };
70
+
71
+ function resolveIcon(variant: EmptyPlaceholderVariant, iconName?: string) {
72
+ if (variant === "error") return Cancel01Icon;
73
+ if (variant === "permission") return LockIcon;
74
+ if (iconName) return getIcon(iconName);
75
+ return InboxIcon;
76
+ }
77
+
78
+ function resolveIconColor(variant: EmptyPlaceholderVariant): string {
79
+ if (variant === "error") return "text-destructive";
80
+ return "text-muted-foreground/50";
81
+ }
82
+
83
+ export function EmptyPlaceholder({
84
+ variant = "first-use",
85
+ icon,
86
+ lottieUrl,
87
+ title,
88
+ description,
89
+ cta,
90
+ ctaSecondary,
91
+ }: EmptyPlaceholderProps): ReactElement {
92
+ const config = VARIANT_CONFIG[variant];
93
+ const iconData = resolveIcon(variant, icon);
94
+ const iconColor = resolveIconColor(variant);
95
+ const showCTA = variant !== "permission" && cta;
96
+ const lottieSize = config.iconSize * 1.8;
97
+
98
+ return (
99
+ <div
100
+ role="status"
101
+ aria-live="polite"
102
+ className={cn("flex flex-col items-center text-center", config.padding)}
103
+ >
104
+ {lottieUrl ? (
105
+ <Suspense
106
+ fallback={<div style={{ width: lottieSize, height: lottieSize }} className="mb-4" />}
107
+ >
108
+ <DotLottieReact
109
+ src={lottieUrl}
110
+ loop
111
+ autoplay
112
+ style={{ width: lottieSize, height: lottieSize }}
113
+ className="mb-4"
114
+ />
115
+ </Suspense>
116
+ ) : (
117
+ <HugeiconsIcon
118
+ icon={iconData}
119
+ size={config.iconSize}
120
+ className={cn(iconColor, "mb-4")}
121
+ aria-hidden="true"
122
+ />
123
+ )}
124
+
125
+ <h3 className="text-foreground text-base font-semibold">{title}</h3>
126
+
127
+ {description && (
128
+ <p className={cn("text-secondary-foreground mt-1.5 text-[13px]", config.maxDescWidth)}>
129
+ {description}
130
+ </p>
131
+ )}
132
+
133
+ {showCTA && (
134
+ <div className="mt-5 flex flex-col items-center gap-3 sm:flex-row">
135
+ {cta.href ? (
136
+ <Button
137
+ variant={cta.intent === "secondary" ? "outline" : "default"}
138
+ disabled={cta.isLoading}
139
+ asChild
140
+ >
141
+ <Link href={cta.href}>{cta.label}</Link>
142
+ </Button>
143
+ ) : (
144
+ <Button
145
+ variant={cta.intent === "secondary" ? "outline" : "default"}
146
+ onClick={cta.onClick}
147
+ disabled={cta.isLoading}
148
+ >
149
+ {cta.label}
150
+ </Button>
151
+ )}
152
+ </div>
153
+ )}
154
+
155
+ {ctaSecondary && (
156
+ <Link href={ctaSecondary.href} className="text-info mt-2.5 text-xs hover:underline">
157
+ {ctaSecondary.label} &rarr;
158
+ </Link>
159
+ )}
160
+ </div>
161
+ );
162
+ }
@@ -0,0 +1,154 @@
1
+ /**
2
+ * EntityItem — data-driven renderable entity row (avatar/icon + title + description + actions).
3
+ *
4
+ * Composes the ReUI Item primitive with Avatar. Used by selection surfaces, list
5
+ * regions, and inspector headers. All visible text is caller-supplied (already
6
+ * translated), matching the EmptyPlaceholder/StatRow convention.
7
+ *
8
+ * Interaction is scoped to the title (Link or button) and to explicit actions —
9
+ * the whole row is never made interactive, so action buttons never nest inside a
10
+ * link/button (avoids the nested-interactive a11y trap).
11
+ */
12
+
13
+ import { type ReactElement, type ReactNode } from "react";
14
+ import { HugeiconsIcon } from "@hugeicons/react";
15
+ import { Link } from "@inertiajs/react";
16
+
17
+ import { getIcon } from "@/base/utils/icons";
18
+ import { Avatar, AvatarFallback, AvatarImage } from "@/primitives/reui/avatar";
19
+ import { Button } from "@/primitives/reui/button";
20
+ import {
21
+ Item,
22
+ ItemActions,
23
+ ItemContent,
24
+ ItemDescription,
25
+ ItemMedia,
26
+ ItemTitle,
27
+ } from "@/primitives/reui/item";
28
+
29
+ export interface EntityItemAvatar {
30
+ /** Image URL. Falls back to `fallback` (typically initials) when missing or it fails to load. */
31
+ src?: string;
32
+ /** Fallback content, typically initials. */
33
+ fallback?: string;
34
+ /** Accessible label for the avatar image. */
35
+ alt?: string;
36
+ }
37
+
38
+ export interface EntityItemAction {
39
+ id: string;
40
+ label: string;
41
+ /** Icon registry key. */
42
+ icon?: string;
43
+ href?: string;
44
+ onClick?: () => void;
45
+ intent?: "primary" | "secondary";
46
+ disabled?: boolean;
47
+ }
48
+
49
+ export interface EntityItemProps {
50
+ title: ReactNode;
51
+ description?: ReactNode;
52
+ /** Avatar media. Takes precedence over `icon`. */
53
+ avatar?: EntityItemAvatar;
54
+ /** Icon registry key for icon media. Ignored when `avatar` is set. */
55
+ icon?: string;
56
+ actions?: EntityItemAction[];
57
+ variant?: "default" | "outline" | "muted";
58
+ size?: "default" | "sm";
59
+ /** Makes the title a navigation link. */
60
+ href?: string;
61
+ /** Makes the title an action button. Ignored when `href` is set. */
62
+ onClick?: () => void;
63
+ className?: string;
64
+ }
65
+
66
+ export function EntityItem({
67
+ title,
68
+ description,
69
+ avatar,
70
+ icon,
71
+ actions,
72
+ variant = "default",
73
+ size = "default",
74
+ href,
75
+ onClick,
76
+ className,
77
+ }: EntityItemProps): ReactElement {
78
+ const media = avatar ? (
79
+ <Avatar size={size === "sm" ? "sm" : "default"}>
80
+ {avatar.src && <AvatarImage src={avatar.src} alt={avatar.alt ?? ""} />}
81
+ {avatar.fallback && <AvatarFallback>{avatar.fallback}</AvatarFallback>}
82
+ </Avatar>
83
+ ) : icon ? (
84
+ <ItemMedia variant="icon">
85
+ <HugeiconsIcon icon={getIcon(icon)} aria-hidden="true" />
86
+ </ItemMedia>
87
+ ) : null;
88
+
89
+ const titleNode = href ? (
90
+ <Link href={href} className="hover:text-primary hover:underline">
91
+ {title}
92
+ </Link>
93
+ ) : onClick ? (
94
+ <button
95
+ type="button"
96
+ onClick={onClick}
97
+ className="hover:text-primary text-left hover:underline"
98
+ >
99
+ {title}
100
+ </button>
101
+ ) : (
102
+ title
103
+ );
104
+
105
+ return (
106
+ <Item variant={variant} size={size} className={className}>
107
+ {media}
108
+ <ItemContent>
109
+ <ItemTitle>{titleNode}</ItemTitle>
110
+ {description && <ItemDescription>{description}</ItemDescription>}
111
+ </ItemContent>
112
+ {actions && actions.length > 0 && (
113
+ <ItemActions>
114
+ {actions.map((action) => {
115
+ const content = (
116
+ <>
117
+ {action.icon && (
118
+ <HugeiconsIcon
119
+ icon={getIcon(action.icon)}
120
+ className="size-4"
121
+ aria-hidden="true"
122
+ />
123
+ )}
124
+ {action.label}
125
+ </>
126
+ );
127
+ const buttonVariant = action.intent === "primary" ? "default" : "outline";
128
+ return action.href ? (
129
+ <Button
130
+ key={action.id}
131
+ variant={buttonVariant}
132
+ size="sm"
133
+ disabled={action.disabled}
134
+ asChild
135
+ >
136
+ <Link href={action.href}>{content}</Link>
137
+ </Button>
138
+ ) : (
139
+ <Button
140
+ key={action.id}
141
+ variant={buttonVariant}
142
+ size="sm"
143
+ disabled={action.disabled}
144
+ onClick={action.onClick}
145
+ >
146
+ {content}
147
+ </Button>
148
+ );
149
+ })}
150
+ </ItemActions>
151
+ )}
152
+ </Item>
153
+ );
154
+ }
@@ -0,0 +1,256 @@
1
+ /**
2
+ * FilterBar — filter trigger button + popover/sheet with available filters.
3
+ *
4
+ * Desktop (>=1024px): Popover. Tablet/Mobile: Sheet from bottom.
5
+ *
6
+ * @see NV-05-ux-blocks.md §1.2 toolbar anatomy
7
+ */
8
+
9
+ import { Fragment, useState, type ReactElement } from "react";
10
+ import { FilterIcon } from "@hugeicons/core-free-icons";
11
+ import { HugeiconsIcon } from "@hugeicons/react";
12
+
13
+ import { useTranslation } from "@/i18n/useTranslation";
14
+ import { Badge } from "@/primitives/reui/badge";
15
+ import { Button } from "@/primitives/reui/button";
16
+ import { Checkbox } from "@/primitives/reui/checkbox";
17
+ import { Popover, PopoverContent, PopoverTrigger } from "@/primitives/reui/popover";
18
+ import {
19
+ Select,
20
+ SelectContent,
21
+ SelectItem,
22
+ SelectTrigger,
23
+ SelectValue,
24
+ } from "@/primitives/reui/select";
25
+ import { Separator } from "@/primitives/reui/separator";
26
+
27
+ export interface FilterDef {
28
+ key: string;
29
+ label: string;
30
+ type: "select" | "multiselect" | "date_range";
31
+ options?: Array<{ value: string; label: string }>;
32
+ }
33
+
34
+ export interface AppliedFilters {
35
+ [key: string]: string | string[];
36
+ }
37
+
38
+ export interface FilterBarProps {
39
+ filters: FilterDef[];
40
+ applied: AppliedFilters;
41
+ onApply: (key: string, value: string | string[]) => void;
42
+ onRemove: (key: string) => void;
43
+ onClearAll: () => void;
44
+ /** When true, chips are rendered externally (e.g. inline in DataTable toolbar). */
45
+ hideChips?: boolean;
46
+ }
47
+
48
+ export function FilterBar({
49
+ filters,
50
+ applied,
51
+ onApply,
52
+ onRemove,
53
+ onClearAll,
54
+ hideChips = false,
55
+ }: FilterBarProps): ReactElement {
56
+ const { t } = useTranslation();
57
+ const [open, setOpen] = useState(false);
58
+ const appliedCount = Object.keys(applied).length;
59
+
60
+ return (
61
+ <div className={hideChips ? "" : "flex flex-col gap-2"}>
62
+ <Popover open={open} onOpenChange={setOpen}>
63
+ <PopoverTrigger asChild>
64
+ {hideChips ? (
65
+ <button
66
+ className="text-muted-foreground hover:text-foreground hover:border-muted-foreground border-border inline-flex h-[30px] cursor-pointer items-center gap-1 rounded-[5px] border border-dashed px-2.5 text-xs font-medium transition-colors hover:border-solid"
67
+ type="button"
68
+ >
69
+ <svg
70
+ viewBox="0 0 24 24"
71
+ fill="none"
72
+ stroke="currentColor"
73
+ strokeWidth={2.5}
74
+ className="h-2.5 w-2.5"
75
+ >
76
+ <line x1="12" y1="5" x2="12" y2="19" />
77
+ <line x1="5" y1="12" x2="19" y2="12" />
78
+ </svg>
79
+ {t("middag.ui.filter.add")}
80
+ </button>
81
+ ) : (
82
+ <Button variant="outline" size="sm" aria-expanded={open} className="gap-2">
83
+ <HugeiconsIcon icon={FilterIcon} size={14} />
84
+ {t("middag.ui.filter.button")}
85
+ {appliedCount > 0 && (
86
+ <Badge variant="secondary" className="ml-1 h-5 px-1.5 text-[10px]">
87
+ {appliedCount}
88
+ </Badge>
89
+ )}
90
+ </Button>
91
+ )}
92
+ </PopoverTrigger>
93
+ {/*
94
+ Capped and scrollable: the panel grows with the number of fields and,
95
+ once a field draws a checkbox per option instead of one closed select,
96
+ it outgrows the window — measured at 1093px in a 900px viewport, with
97
+ the last options below the fold and no way to reach them.
98
+
99
+ The cap is Radix's own available-height variable rather than a `vh`
100
+ fraction: the panel opens below its trigger, so the room it actually
101
+ has depends on where that trigger sits. From a trigger halfway down the
102
+ page the variable read 590px where `70vh` gave 630 — 40px past the fold.
103
+ */}
104
+ <PopoverContent
105
+ className="max-h-[var(--radix-popover-content-available-height)] w-72 space-y-4 overflow-y-auto p-4"
106
+ align="start"
107
+ >
108
+ <p className="text-sm font-semibold">{t("middag.ui.filter.title")}</p>
109
+ {filters.map((filter) => (
110
+ <div key={filter.key} className="space-y-1.5">
111
+ <label className="text-muted-foreground text-xs font-medium">{filter.label}</label>
112
+ {filter.type === "select" && filter.options && (
113
+ <Select
114
+ value={(applied[filter.key] as string) ?? ""}
115
+ onValueChange={(val) => onApply(filter.key, val)}
116
+ >
117
+ <SelectTrigger className="h-8 text-xs">
118
+ <SelectValue placeholder={t("middag.ui.filter.placeholder")} />
119
+ </SelectTrigger>
120
+ <SelectContent>
121
+ {filter.options.map((opt) => (
122
+ <SelectItem key={opt.value} value={opt.value}>
123
+ {opt.label}
124
+ </SelectItem>
125
+ ))}
126
+ </SelectContent>
127
+ </Select>
128
+ )}
129
+
130
+ {/*
131
+ `multiselect` has been in `FilterDef` from the start and nothing
132
+ drew it — the field rendered as a label with no control under it,
133
+ so a consumer that asked for one silently got a filter nobody
134
+ could set. Checkboxes rather than a multi-value select: the whole
135
+ point is seeing several values on at once, and a closed trigger
136
+ hides exactly that.
137
+
138
+ Unchecking the last value removes the filter instead of applying
139
+ an empty list, which would read as "match nothing" and show an
140
+ empty table where the user meant to stop filtering.
141
+ */}
142
+ {filter.type === "multiselect" && filter.options && (
143
+ <div className="space-y-1.5">
144
+ {filter.options.map((opt) => {
145
+ const current = applied[filter.key];
146
+ const values = Array.isArray(current) ? current : current ? [current] : [];
147
+ const checked = values.includes(opt.value);
148
+ return (
149
+ <label
150
+ key={opt.value}
151
+ className="hover:bg-accent/40 flex cursor-pointer items-center gap-2 rounded px-1 py-0.5 text-xs"
152
+ >
153
+ <Checkbox
154
+ checked={checked}
155
+ onCheckedChange={() => {
156
+ const next = checked
157
+ ? values.filter((value) => value !== opt.value)
158
+ : [...values, opt.value];
159
+ if (next.length === 0) onRemove(filter.key);
160
+ else onApply(filter.key, next);
161
+ }}
162
+ />
163
+ <span className="min-w-0 flex-1 truncate">{opt.label}</span>
164
+ </label>
165
+ );
166
+ })}
167
+ </div>
168
+ )}
169
+ {/*
170
+ `date_range` had been in `FilterDef` from the start with nothing
171
+ drawing it — the same hole `multiselect` had, and it survived the
172
+ fix to that one because each type is its own branch and nobody
173
+ was looking for the sibling.
174
+
175
+ Two native date inputs rather than a calendar popover: the value
176
+ is a pair of days, both ends need to be typeable, and a popover
177
+ inside a popover is a second layer to dismiss.
178
+
179
+ The pair travels as `[from, to]`, and an end left blank stays an
180
+ empty string rather than collapsing the array — position is what
181
+ says which end it is, so dropping one would silently turn "up to
182
+ March" into "from March". Both ends empty removes the filter, for
183
+ the same reason unchecking the last box does.
184
+ */}
185
+ {filter.type === "date_range" && (
186
+ <div className="flex items-center gap-1.5">
187
+ {([0, 1] as const).map((end) => {
188
+ const current = applied[filter.key];
189
+ const pair = Array.isArray(current) ? current : ["", ""];
190
+ return (
191
+ <Fragment key={end}>
192
+ {end === 1 && <span className="text-muted-foreground text-xs">—</span>}
193
+ <input
194
+ type="date"
195
+ className="border-input bg-background h-8 min-w-0 flex-1 rounded-md border px-2 text-xs"
196
+ aria-label={`${filter.label} ${end === 0 ? t("middag.ui.filter.date_from") : t("middag.ui.filter.date_to")}`}
197
+ value={pair[end] ?? ""}
198
+ onChange={(event) => {
199
+ const next = [pair[0] ?? "", pair[1] ?? ""];
200
+ next[end] = event.target.value;
201
+ if (next[0] === "" && next[1] === "") onRemove(filter.key);
202
+ else onApply(filter.key, next);
203
+ }}
204
+ />
205
+ </Fragment>
206
+ );
207
+ })}
208
+ </div>
209
+ )}
210
+ </div>
211
+ ))}
212
+ <Separator />
213
+ <div className="flex justify-end">
214
+ <Button
215
+ variant="ghost"
216
+ size="sm"
217
+ onClick={() => {
218
+ onClearAll();
219
+ setOpen(false);
220
+ }}
221
+ >
222
+ {t("middag.ui.filter.clear")}
223
+ </Button>
224
+ </div>
225
+ </PopoverContent>
226
+ </Popover>
227
+
228
+ {/* Applied filter chips (hidden when hideChips=true — rendered by parent) */}
229
+ {!hideChips && appliedCount > 0 && (
230
+ <div className="flex flex-wrap items-center gap-1.5">
231
+ {Object.entries(applied).map(([key, value]) => {
232
+ const filter = filters.find((f) => f.key === key);
233
+ const displayValue = Array.isArray(value) ? value.join(", ") : value;
234
+ return (
235
+ <Badge key={key} variant="secondary" className="gap-1 pr-1">
236
+ <span className="text-xs">
237
+ {filter?.label ?? key}: {displayValue}
238
+ </span>
239
+ <button
240
+ onClick={() => onRemove(key)}
241
+ className="hover:bg-muted-foreground/20 ml-1 rounded-sm p-0.5"
242
+ aria-label={`${t("middag.ui.filter.remove")} ${filter?.label ?? key}`}
243
+ >
244
+ &times;
245
+ </button>
246
+ </Badge>
247
+ );
248
+ })}
249
+ <button onClick={onClearAll} className="text-primary text-xs hover:underline">
250
+ {t("middag.ui.filter.clear")}
251
+ </button>
252
+ </div>
253
+ )}
254
+ </div>
255
+ );
256
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * FormSection — collapsible fieldset container for form groups.
3
+ *
4
+ * Does not render fields — receives them as children.
5
+ *
6
+ * @see NV-05-ux-blocks.md §2.6
7
+ */
8
+
9
+ import { useState, type ReactElement, type ReactNode } from "react";
10
+ import { ArrowDown01Icon, ArrowRight01Icon } from "@hugeicons/core-free-icons";
11
+ import { HugeiconsIcon } from "@hugeicons/react";
12
+
13
+ import { useTranslation } from "@/i18n/useTranslation";
14
+ import { cn } from "@/lib/utils";
15
+ import { Button } from "@/primitives/reui/button";
16
+
17
+ export interface FormSectionProps {
18
+ id: string;
19
+ title?: string;
20
+ description?: string;
21
+ children: ReactNode;
22
+ defaultCollapsed?: boolean;
23
+ hasErrors?: boolean;
24
+ errorCount?: number;
25
+ }
26
+
27
+ export function FormSection({
28
+ id,
29
+ title,
30
+ description,
31
+ children,
32
+ defaultCollapsed = false,
33
+ hasErrors = false,
34
+ errorCount,
35
+ }: FormSectionProps): ReactElement {
36
+ const { t } = useTranslation();
37
+ const [collapsed, setCollapsed] = useState(defaultCollapsed && !hasErrors);
38
+ const contentId = `${id}-content`;
39
+ const isCollapsible = !!title;
40
+ const expanded = !collapsed || hasErrors;
41
+
42
+ return (
43
+ <fieldset className="border-border space-y-5 rounded-lg border p-6">
44
+ {title && <legend className="sr-only">{title}</legend>}
45
+
46
+ {title && (
47
+ <div className="-mt-2 flex items-center justify-between">
48
+ {isCollapsible ? (
49
+ <Button
50
+ type="button"
51
+ variant="ghost"
52
+ size="sm"
53
+ onClick={() => !hasErrors && setCollapsed(!collapsed)}
54
+ aria-expanded={expanded}
55
+ aria-controls={contentId}
56
+ className="-ml-2 flex items-center gap-2 px-2"
57
+ disabled={hasErrors}
58
+ >
59
+ <HugeiconsIcon icon={expanded ? ArrowDown01Icon : ArrowRight01Icon} size={14} />
60
+ <span className="text-foreground text-lg font-semibold">{title}</span>
61
+ </Button>
62
+ ) : (
63
+ <h3 className="text-foreground text-lg font-semibold">{title}</h3>
64
+ )}
65
+
66
+ {hasErrors && errorCount !== undefined && errorCount > 0 && (
67
+ <span className="text-destructive text-xs">
68
+ ({t("middag.ui.form.error", { count: errorCount })})
69
+ </span>
70
+ )}
71
+ </div>
72
+ )}
73
+
74
+ {description && expanded && <p className="text-muted-foreground text-xs">{description}</p>}
75
+
76
+ <div
77
+ id={contentId}
78
+ className={cn(
79
+ "space-y-5 transition-[opacity,height] duration-200 ease-[var(--ease-default)]",
80
+ expanded ? "opacity-100" : "hidden opacity-0",
81
+ )}
82
+ >
83
+ {children}
84
+ </div>
85
+ </fieldset>
86
+ );
87
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * JsonBlock — collapsible JSON payload display.
3
+ */
4
+
5
+ import { useState, type ReactElement } from "react";
6
+
7
+ import { cn } from "@/lib/utils";
8
+
9
+ export function JsonBlock({ data }: { data: Record<string, unknown> | unknown[] }): ReactElement {
10
+ const [expanded, setExpanded] = useState(false);
11
+ const json = JSON.stringify(data, null, 2);
12
+ const keys = Array.isArray(data) ? data : Object.keys(data);
13
+
14
+ if (keys.length === 0) {
15
+ return <></>;
16
+ }
17
+
18
+ return (
19
+ <>
20
+ <button
21
+ type="button"
22
+ onClick={() => setExpanded(!expanded)}
23
+ className={cn(
24
+ "rounded px-1 py-0.5 font-mono text-xs transition-colors",
25
+ expanded
26
+ ? "bg-muted text-foreground"
27
+ : "bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground",
28
+ )}
29
+ >
30
+ {expanded ? "▾ context" : "{…}"}
31
+ </button>
32
+ {expanded && (
33
+ <pre className="bg-muted/30 mt-1 block w-full overflow-x-auto rounded p-2 font-mono text-xs">
34
+ {json}
35
+ </pre>
36
+ )}
37
+ </>
38
+ );
39
+ }