@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,480 @@
1
+ /**
2
+ * FormPanelBlock — schema-driven form rendering with react-hook-form + Zod validation.
3
+ *
4
+ * Receives form schema from server, renders fields via FormField router,
5
+ * validates client-side via Zod (generated from schema), and submits via Inertia.
6
+ *
7
+ * Validation modes (meta.validation):
8
+ * - 'both' (default): client + server validation
9
+ * - 'client': client-only (no Inertia error handling)
10
+ * - 'server': server-only (legacy, no Zod schema)
11
+ *
12
+ * Heavy deps (react-hook-form + zod) are isolated to this module so the engine
13
+ * only loads them when a page actually renders a form_panel — see the lazy
14
+ * wrapper in FormPanelBlock.lazy.tsx, which is what register-defaults registers.
15
+ */
16
+
17
+ import { useCallback, useEffect, useMemo, useRef, useState, type ReactElement } from "react";
18
+ import { useForm, useWatch } from "react-hook-form";
19
+ import type { FieldValues, Resolver, ResolverOptions } from "react-hook-form";
20
+ import { zodResolver } from "@hookform/resolvers/zod";
21
+ import { router } from "@inertiajs/core";
22
+
23
+ import { buildFormSchema } from "@/base/form/form-schema-builder";
24
+ import { extractFields, isFieldRequired, isFieldVisible } from "@/base/form/form-utils";
25
+ import { FormField } from "@/base/form/FormField";
26
+ import { EmptyPlaceholder } from "@/base/partials/EmptyPlaceholder";
27
+ import { FormSection } from "@/base/partials/FormSection";
28
+ import type { FormErrors, FormPanelBlockData, FormSchemaNode } from "@/contracts/block-data";
29
+ import type { BlockProps } from "@/engine/registries";
30
+ import { renderLabel } from "@/i18n/render-label";
31
+ import { resolveFieldError } from "@/i18n/resolve-field-error";
32
+ import { useTranslation } from "@/i18n/useTranslation";
33
+ import { TEST_IDS } from "@/lib/test-ids";
34
+ import { cn } from "@/lib/utils";
35
+ import { Alert, AlertDescription, AlertTitle } from "@/primitives/reui/alert";
36
+ import { Button } from "@/primitives/reui/button";
37
+ import {
38
+ Dialog,
39
+ DialogContent,
40
+ DialogDescription,
41
+ DialogFooter,
42
+ DialogHeader,
43
+ DialogTitle,
44
+ } from "@/primitives/reui/dialog";
45
+ import { Separator } from "@/primitives/reui/separator";
46
+
47
+ /** Dynamic form values — keys are server-defined field keys, values are mixed types. */
48
+ type DynamicFormValues = Record<string, unknown>;
49
+
50
+ function defaultValueForField(
51
+ field: ReturnType<typeof extractFields>[number],
52
+ values: DynamicFormValues,
53
+ ) {
54
+ const existing = values[field.key];
55
+ if (existing !== undefined && existing !== null) return existing;
56
+
57
+ switch (field.component) {
58
+ case "int":
59
+ case "float":
60
+ case "currency":
61
+ case "slider":
62
+ case "rating":
63
+ return null;
64
+ case "checkbox":
65
+ case "switch":
66
+ return false;
67
+ case "multiselect":
68
+ case "tags":
69
+ return [];
70
+ default:
71
+ return "";
72
+ }
73
+ }
74
+
75
+ function fieldValue(field: ReturnType<typeof extractFields>[number], values: DynamicFormValues) {
76
+ if (Object.prototype.hasOwnProperty.call(values, field.key)) {
77
+ return values[field.key];
78
+ }
79
+ return defaultValueForField(field, values);
80
+ }
81
+
82
+ // ── Schema renderer ──────────────────────────────────────────────────────────
83
+
84
+ function SchemaRenderer({
85
+ nodes,
86
+ values,
87
+ errors,
88
+ onChange,
89
+ sourceValues,
90
+ }: {
91
+ nodes: FormSchemaNode[];
92
+ values: Record<string, unknown>;
93
+ errors: Record<string, string>;
94
+ onChange: (key: string, value: unknown) => void;
95
+ sourceValues: Record<string, unknown>;
96
+ }): ReactElement {
97
+ return (
98
+ <>
99
+ {nodes.map((node, index) => {
100
+ switch (node.kind) {
101
+ case "field": {
102
+ if (!isFieldVisible(node, values)) return null;
103
+ return (
104
+ <FormField
105
+ key={node.key}
106
+ field={node}
107
+ value={fieldValue(node, values)}
108
+ onChange={(val) => onChange(node.key, val)}
109
+ error={errors[node.key]}
110
+ sourceValues={sourceValues}
111
+ />
112
+ );
113
+ }
114
+ case "section":
115
+ return (
116
+ <FormSection
117
+ key={node.id}
118
+ id={node.id}
119
+ title={node.label}
120
+ defaultCollapsed={node.defaultCollapsed}
121
+ hasErrors={node.children.some((c) => c.kind === "field" && !!errors[c.key])}
122
+ errorCount={
123
+ node.children.filter((c) => c.kind === "field" && !!errors[c.key]).length
124
+ }
125
+ >
126
+ <SchemaRenderer
127
+ nodes={node.children}
128
+ values={values}
129
+ errors={errors}
130
+ onChange={onChange}
131
+ sourceValues={sourceValues}
132
+ />
133
+ </FormSection>
134
+ );
135
+ case "group":
136
+ return (
137
+ <div
138
+ key={node.id}
139
+ className={cn("grid gap-6", node.columns === 2 ? "md:grid-cols-2" : "grid-cols-1")}
140
+ >
141
+ <SchemaRenderer
142
+ nodes={node.children}
143
+ values={values}
144
+ errors={errors}
145
+ onChange={onChange}
146
+ sourceValues={sourceValues}
147
+ />
148
+ </div>
149
+ );
150
+ case "header":
151
+ return (
152
+ <div key={`header-${index}`} className="space-y-2">
153
+ <Separator />
154
+ <h4 className="text-foreground text-base font-semibold">{node.label}</h4>
155
+ </div>
156
+ );
157
+ default:
158
+ return null;
159
+ }
160
+ })}
161
+ </>
162
+ );
163
+ }
164
+
165
+ // ── FormPanelBlock ───────────────────────────────────────────────────────────
166
+
167
+ export function FormPanelBlock({ block }: BlockProps<FormPanelBlockData>): ReactElement {
168
+ const { t } = useTranslation();
169
+ const { data } = block;
170
+ const allFields = useMemo(() => extractFields(data.schema), [data.schema]);
171
+ // Authoritative set of keys that map to a rendered field. Server errors whose
172
+ // key is NOT here (form-level "_", dotted/nested paths, unknown keys) are
173
+ // surfaced in a form-level alert instead of being routed through RHF.
174
+ const fieldKeys = useMemo(() => new Set(allFields.map((f) => f.key)), [allFields]);
175
+ const validationMode = data.meta.validation ?? "both";
176
+ const useClientValidation = validationMode !== "server";
177
+
178
+ const defaultValues = useMemo(
179
+ () => Object.fromEntries(allFields.map((f) => [f.key, defaultValueForField(f, data.values)])),
180
+ [allFields, data.values],
181
+ );
182
+
183
+ // ── react-hook-form setup ──────────────────────────────────────────────
184
+
185
+ // Schema ref holds the latest Zod schema. Updated when field visibility changes.
186
+ // The resolver reads from this ref so it always validates against current state.
187
+ const schemaRef = useRef(
188
+ useClientValidation ? buildFormSchema(data.schema, defaultValues, t) : null,
189
+ );
190
+
191
+ const stableResolver: Resolver<DynamicFormValues> | undefined = useMemo(() => {
192
+ if (!useClientValidation) return undefined;
193
+ return async (
194
+ values: DynamicFormValues,
195
+ _context: unknown,
196
+ options: ResolverOptions<FieldValues>,
197
+ ) => {
198
+ if (!schemaRef.current) return { values, errors: {} };
199
+ return zodResolver(schemaRef.current)(values, _context, options);
200
+ };
201
+ }, [useClientValidation]);
202
+
203
+ const form = useForm<DynamicFormValues>({
204
+ defaultValues,
205
+ mode: "onTouched",
206
+ resolver: stableResolver,
207
+ });
208
+
209
+ const watchedValues = useWatch({ control: form.control });
210
+ const currentValues: DynamicFormValues = (watchedValues as DynamicFormValues) ?? defaultValues;
211
+
212
+ // Rebuild Zod schema when the conditional state of any field changes.
213
+ // Visibility (visible_when/hidden_when) and required state (required_when,
214
+ // which is also suppressed by disabled_when) both change the generated schema,
215
+ // so the key must track both — not visibility alone.
216
+ const schemaStateKey = allFields
217
+ .map(
218
+ (f) =>
219
+ `${isFieldVisible(f, currentValues) ? "1" : "0"}${isFieldRequired(f, currentValues) ? "1" : "0"}`,
220
+ )
221
+ .join("");
222
+
223
+ useEffect(() => {
224
+ if (useClientValidation) {
225
+ schemaRef.current = buildFormSchema(data.schema, currentValues, t);
226
+ }
227
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on schemaStateKey, not currentValues
228
+ }, [useClientValidation, data.schema, t, schemaStateKey]);
229
+
230
+ const [showDirtyDialog, setShowDirtyDialog] = useState(false);
231
+ // Upload progress (0-100) while a multipart submit is in flight; null otherwise.
232
+ const [uploadProgress, setUploadProgress] = useState<number | null>(null);
233
+ // Non-field server errors captured at submit time (Inertia onError). Kept out
234
+ // of RHF so dotted keys are not interpreted as nested paths and lost.
235
+ const [submitFormErrors, setSubmitFormErrors] = useState<FormErrors>({});
236
+
237
+ // Reset the form when the server sends new initial values (e.g. an Inertia
238
+ // partial reload that normalizes data). Without this, useForm keeps the
239
+ // mount-time defaults and the UI can submit stale input.
240
+ //
241
+ // Keyed on the serialized values: a new prop object with identical content
242
+ // (common with Inertia) produces the same key and skips the reset, so
243
+ // in-progress edits are not clobbered and no render loop forms. The first
244
+ // run is skipped because useForm already initialized with these defaults.
245
+ // reset() clears the dirty flag, so this never marks the form dirty.
246
+ const initialValuesKey = JSON.stringify(data.values);
247
+ const isFirstValuesSync = useRef(true);
248
+ useEffect(() => {
249
+ if (isFirstValuesSync.current) {
250
+ isFirstValuesSync.current = false;
251
+ return;
252
+ }
253
+ form.reset(defaultValues);
254
+ // reset() clears errors — re-apply any server errors that survive the reload.
255
+ for (const [field, err] of Object.entries(data.errors)) {
256
+ if (!fieldKeys.has(field)) continue; // non-field/dotted -> formLevelErrors
257
+ form.setError(field, { type: "server", message: resolveFieldError(err, t) });
258
+ }
259
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed on initialValuesKey only
260
+ }, [initialValuesKey]);
261
+
262
+ // Sync server errors into react-hook-form (re-translated client-side).
263
+ const serverErrorRef = JSON.stringify(data.errors);
264
+ useEffect(() => {
265
+ if (Object.keys(data.errors).length > 0) {
266
+ for (const [field, err] of Object.entries(data.errors)) {
267
+ if (!fieldKeys.has(field)) continue; // non-field/dotted -> formLevelErrors
268
+ form.setError(field, { type: "server", message: resolveFieldError(err, t) });
269
+ }
270
+ }
271
+ // eslint-disable-next-line react-hooks/exhaustive-deps
272
+ }, [serverErrorRef]);
273
+
274
+ const { isDirty, isSubmitting } = form.formState;
275
+
276
+ // Browser beforeunload warning
277
+ useEffect(() => {
278
+ if (!isDirty) return;
279
+ const handler = (e: BeforeUnloadEvent) => {
280
+ e.preventDefault();
281
+ };
282
+ window.addEventListener("beforeunload", handler);
283
+ return () => window.removeEventListener("beforeunload", handler);
284
+ }, [isDirty]);
285
+
286
+ // ── Handlers ───────────────────────────────────────────────────────────
287
+
288
+ const handleFieldChange = useCallback(
289
+ (key: string, value: unknown) => {
290
+ form.setValue(key, value, {
291
+ shouldDirty: true,
292
+ shouldValidate: form.formState.isSubmitted,
293
+ });
294
+ form.clearErrors(key);
295
+ },
296
+ [form],
297
+ );
298
+
299
+ const onSubmit = useCallback(
300
+ (payload: DynamicFormValues) => {
301
+ // Clear stale form-level errors from a previous attempt.
302
+ setSubmitFormErrors({});
303
+
304
+ // Filter to visible fields only
305
+ const visibleFields = allFields.filter((f) => isFieldVisible(f, payload));
306
+ const visiblePayload = Object.fromEntries(visibleFields.map((f) => [f.key, payload[f.key]]));
307
+
308
+ // Force multipart encoding when any value is a File so Inertia streams
309
+ // the upload (and onProgress reports real bytes-sent percentages).
310
+ const hasFile = Object.values(visiblePayload).some(
311
+ (v) => v instanceof File || (Array.isArray(v) && v.some((item) => item instanceof File)),
312
+ );
313
+
314
+ const method = data.method === "put" ? "put" : data.method === "patch" ? "patch" : "post";
315
+
316
+ // react-hook-form's isSubmitting stays true only while the promise
317
+ // returned by onSubmit is pending — router[method]() itself is
318
+ // fire-and-forget, so without wrapping it in a promise resolved from
319
+ // onFinish, isSubmitting flips back to false on the next microtask,
320
+ // well before the actual request completes: the Save button's loading
321
+ // state never visibly shows.
322
+ return new Promise<void>((resolve) => {
323
+ router[method](data.action, visiblePayload as Record<string, string>, {
324
+ forceFormData: hasFile,
325
+ onProgress: (event) => {
326
+ if (event && typeof event.percentage === "number") {
327
+ setUploadProgress(Math.round(event.percentage));
328
+ }
329
+ },
330
+ onError: (errors) => {
331
+ // Inertia types page-prop errors as flat strings, but v0.11.0 sends
332
+ // structured FieldError objects on the wire — cast through unknown.
333
+ const nonField: FormErrors = {};
334
+ for (const [field, err] of Object.entries(errors as unknown as FormErrors)) {
335
+ if (fieldKeys.has(field)) {
336
+ form.setError(field, { type: "server", message: resolveFieldError(err, t) });
337
+ } else {
338
+ // Form-level / dotted / unknown keys: surface via the alert, not RHF.
339
+ nonField[field] = err;
340
+ }
341
+ }
342
+ if (Object.keys(nonField).length > 0) {
343
+ setSubmitFormErrors((prev) => ({ ...prev, ...nonField }));
344
+ }
345
+ },
346
+ onFinish: () => {
347
+ setUploadProgress(null);
348
+ resolve();
349
+ },
350
+ });
351
+ });
352
+ },
353
+ [allFields, data, form, t, fieldKeys],
354
+ );
355
+
356
+ const handleCancel = useCallback(() => {
357
+ if (isDirty) {
358
+ setShowDirtyDialog(true);
359
+ } else if (data.meta.cancelHref) {
360
+ router.visit(data.meta.cancelHref);
361
+ } else {
362
+ window.history.back();
363
+ }
364
+ }, [isDirty, data.meta.cancelHref]);
365
+
366
+ // Derive errors from react-hook-form state for SchemaRenderer
367
+ const displayErrors = useMemo(() => {
368
+ const errors: Record<string, string> = {};
369
+ for (const [key, err] of Object.entries(form.formState.errors)) {
370
+ if (err?.message) errors[key] = err.message as string;
371
+ }
372
+ return errors;
373
+ }, [form.formState.errors]);
374
+
375
+ // Form-level errors: any server error whose key is not a rendered field key
376
+ // (the PHP "_" orphan key, dotted/nested paths, or unknown keys). Derived
377
+ // straight from the wire prop + submit-time errors and deduped by key, so
378
+ // dotted keys survive intact (never routed through RHF path interpretation).
379
+ const formLevelErrors = useMemo(() => {
380
+ const byKey = new Map<string, string>();
381
+ const collect = (src: FormErrors) => {
382
+ for (const [key, err] of Object.entries(src)) {
383
+ if (fieldKeys.has(key)) continue;
384
+ const message = resolveFieldError(err, t);
385
+ if (message) byKey.set(key, message);
386
+ }
387
+ };
388
+ collect(data.errors);
389
+ collect(submitFormErrors);
390
+ return Array.from(byKey, ([key, message]) => ({ key, message }));
391
+ }, [data.errors, submitFormErrors, fieldKeys, t]);
392
+
393
+ // No visible fields
394
+ const visibleFields = allFields.filter((f) => isFieldVisible(f, currentValues));
395
+ if (visibleFields.length === 0 && data.schema.length === 0) {
396
+ return <EmptyPlaceholder variant="inline" title={t("middag.ui.form.no_fields")} />;
397
+ }
398
+
399
+ return (
400
+ <>
401
+ <form
402
+ onSubmit={form.handleSubmit(onSubmit)}
403
+ className="mx-auto max-w-[720px] space-y-6"
404
+ noValidate
405
+ role="form"
406
+ aria-label={renderLabel(block.title, t) || t("middag.ui.form.default_title")}
407
+ >
408
+ {/* Form-level / non-field server errors (keys with no matching field) */}
409
+ {formLevelErrors.length > 0 && (
410
+ <Alert variant="destructive">
411
+ <AlertTitle>{t("middag.ui.form.errors_title")}</AlertTitle>
412
+ <AlertDescription>
413
+ <ul className="list-disc ps-4">
414
+ {formLevelErrors.map((e) => (
415
+ <li key={e.key}>{e.message}</li>
416
+ ))}
417
+ </ul>
418
+ </AlertDescription>
419
+ </Alert>
420
+ )}
421
+
422
+ <SchemaRenderer
423
+ nodes={data.schema}
424
+ values={currentValues}
425
+ errors={displayErrors}
426
+ onChange={handleFieldChange}
427
+ sourceValues={currentValues}
428
+ />
429
+
430
+ {/* Actions */}
431
+ <div className="flex gap-3 pt-4">
432
+ <Button
433
+ type="submit"
434
+ data-testid={TEST_IDS.formSubmit}
435
+ disabled={isSubmitting}
436
+ aria-disabled={isSubmitting}
437
+ aria-busy={isSubmitting}
438
+ >
439
+ {isSubmitting
440
+ ? uploadProgress !== null
441
+ ? `${t("middag.ui.form.saving")} ${uploadProgress}%`
442
+ : t("middag.ui.form.saving")
443
+ : (data.meta.submitLabel ?? t("middag.ui.form.save"))}
444
+ </Button>
445
+ <Button type="button" variant="outline" onClick={handleCancel}>
446
+ {data.meta.cancelLabel ?? t("middag.ui.cancel")}
447
+ </Button>
448
+ </div>
449
+ </form>
450
+
451
+ {/* Dirty navigation dialog */}
452
+ <Dialog open={showDirtyDialog} onOpenChange={setShowDirtyDialog}>
453
+ <DialogContent>
454
+ <DialogHeader>
455
+ <DialogTitle>{t("middag.ui.form.dirty_title")}</DialogTitle>
456
+ <DialogDescription>{t("middag.ui.form.dirty_message")}</DialogDescription>
457
+ </DialogHeader>
458
+ <DialogFooter>
459
+ <Button variant="outline" onClick={() => setShowDirtyDialog(false)}>
460
+ {t("middag.ui.cancel")}
461
+ </Button>
462
+ <Button
463
+ variant="destructive"
464
+ onClick={() => {
465
+ setShowDirtyDialog(false);
466
+ if (data.meta.cancelHref) {
467
+ router.visit(data.meta.cancelHref);
468
+ } else {
469
+ window.history.back();
470
+ }
471
+ }}
472
+ >
473
+ {t("middag.ui.form.dirty_leave")}
474
+ </Button>
475
+ </DialogFooter>
476
+ </DialogContent>
477
+ </Dialog>
478
+ </>
479
+ );
480
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * LinkListBlock — vertical list of links with icon, label, and description.
3
+ *
4
+ * Items with href: null are hidden. Internal destinations navigate through
5
+ * Inertia; external links stay plain anchors and open in a new tab.
6
+ *
7
+ * @see ADR-807 block catalog
8
+ */
9
+
10
+ import type { ReactElement } from "react";
11
+ import { ArrowUpRight01Icon } from "@hugeicons/core-free-icons";
12
+ import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
13
+ import { Link } from "@inertiajs/react";
14
+
15
+ import { getIcon } from "@/base/utils/icons";
16
+ import type { LinkListBlockData } from "@/contracts/block-data";
17
+ import type { BlockProps } from "@/engine/registries";
18
+ import { cn } from "@/lib/utils";
19
+
20
+ export function LinkListBlock({ block }: BlockProps<LinkListBlockData>): ReactElement {
21
+ const { items } = block.data;
22
+ const { meta } = block;
23
+ const borderless = (meta as Record<string, unknown> | undefined)?.borderless === true;
24
+ /**
25
+ * Tighter rows, for a list that is a control rather than a destination.
26
+ *
27
+ * The default padding suits a handful of navigation links. A facet list runs
28
+ * to a dozen entries of one short line each, and at three rems apiece it
29
+ * outgrows the column it sits in.
30
+ */
31
+ const dense = (meta as Record<string, unknown> | undefined)?.dense === true;
32
+ const visible = items.filter((item) => item.href != null);
33
+
34
+ if (visible.length === 0) {
35
+ return <></>;
36
+ }
37
+
38
+ return (
39
+ <div className={cn(borderless ? "space-y-0.5" : "divide-border divide-y rounded-lg border")}>
40
+ {visible.map((item, index) => {
41
+ // Internal destinations go through Inertia so the page swaps instead of
42
+ // reloading; a raw anchor threw away the whole document — and with it the
43
+ // scroll position and every bit of client state — to move one link away.
44
+ // External ones stay anchors: Inertia would try to render the response as
45
+ // a page.
46
+ const Anchor = item.external ? "a" : Link;
47
+ return (
48
+ <Anchor
49
+ key={`${item.href}-${index}`}
50
+ href={item.href!}
51
+ target={item.external ? "_blank" : undefined}
52
+ rel={item.external ? "noopener noreferrer" : undefined}
53
+ className={cn(
54
+ "flex gap-3 transition-colors",
55
+ // Centred while dense: with one line of text the row reads as a
56
+ // control, and top-alignment leaves the count sitting high.
57
+ dense ? "items-center px-3 py-1.5" : "items-start px-4 py-3",
58
+ borderless ? "hover:bg-accent/50 rounded-md" : "hover:bg-accent/50",
59
+ item.active && "bg-accent text-accent-foreground font-medium",
60
+ )}
61
+ aria-current={item.active ? "true" : undefined}
62
+ >
63
+ {item.icon && (
64
+ <HugeiconsIcon
65
+ icon={getIcon(item.icon) as unknown as IconSvgElement}
66
+ className="text-muted-foreground mt-0.5 size-4"
67
+ />
68
+ )}
69
+ <div className="min-w-0 flex-1">
70
+ <span className={cn("block truncate text-sm", !dense && "font-medium")}>
71
+ {item.label}
72
+ </span>
73
+ {item.description && (
74
+ <p className="text-muted-foreground text-xs">{item.description}</p>
75
+ )}
76
+ </div>
77
+ {/* Pinned right, muted, and never squeezed — the label truncates first. */}
78
+ {item.trailing && (
79
+ <span className="text-muted-foreground shrink-0 text-xs tabular-nums">
80
+ {item.trailing}
81
+ </span>
82
+ )}
83
+ {item.external && (
84
+ <HugeiconsIcon
85
+ icon={ArrowUpRight01Icon as unknown as IconSvgElement}
86
+ className="text-muted-foreground mt-0.5 size-3"
87
+ />
88
+ )}
89
+ </Anchor>
90
+ );
91
+ })}
92
+ </div>
93
+ );
94
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MarkdownPanelBlock — renders sanitized markdown content in a Card.
3
+ *
4
+ * Delegates to MarkdownContent partial when available.
5
+ * Stub renders raw content in a prose-style container.
6
+ *
7
+ * @see NV-05-ux-blocks.md §8
8
+ */
9
+
10
+ import { lazy, Suspense, type ReactElement } from "react";
11
+
12
+ import type { MarkdownPanelBlockData } from "@/contracts/block-data";
13
+ import type { BlockProps } from "@/engine/registries";
14
+ import { renderLabel } from "@/i18n/render-label";
15
+ import { useTranslation } from "@/i18n/useTranslation";
16
+ import { Card, CardContent, CardHeader, CardTitle } from "@/primitives/reui/card";
17
+ import { Skeleton } from "@/primitives/reui/skeleton";
18
+
19
+ // Lazy load MarkdownContent to keep bundle small (react-markdown ~55KB)
20
+ const MarkdownContent = lazy(() =>
21
+ import("@/base/partials/MarkdownContent").then((m) => ({
22
+ default: m.MarkdownContent,
23
+ })),
24
+ );
25
+
26
+ function MarkdownSkeleton(): ReactElement {
27
+ return (
28
+ <div className="space-y-3">
29
+ <Skeleton className="h-4 w-[90%]" />
30
+ <Skeleton className="h-4 w-[75%]" />
31
+ <Skeleton className="h-4 w-[85%]" />
32
+ <Skeleton className="h-4 w-[60%]" />
33
+ </div>
34
+ );
35
+ }
36
+
37
+ export function MarkdownPanelBlock({ block }: BlockProps<MarkdownPanelBlockData>): ReactElement {
38
+ const { t } = useTranslation();
39
+ const { data, title, meta } = block;
40
+ const isLoading = meta?.loading === true;
41
+
42
+ return (
43
+ <Card>
44
+ {title && (
45
+ <CardHeader>
46
+ <CardTitle className="text-xl font-semibold">{renderLabel(title, t)}</CardTitle>
47
+ </CardHeader>
48
+ )}
49
+ <CardContent className="p-6">
50
+ {isLoading ? (
51
+ <MarkdownSkeleton />
52
+ ) : (
53
+ <Suspense fallback={<MarkdownSkeleton />}>
54
+ <MarkdownContent content={data.content} maxHeight={data.maxHeight} />
55
+ </Suspense>
56
+ )}
57
+ </CardContent>
58
+ </Card>
59
+ );
60
+ }