@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.
- package/README.md +7 -0
- package/dist-lib/{FormField-Bj43PjHH.js → FormField-Csx8hGAW.js} +1956 -1936
- package/dist-lib/{FormPanelBlock-C6eDfGoI.js → FormPanelBlock-Bmd0DpiX.js} +337 -337
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/LinkListBlock.d.ts +2 -1
- package/dist-lib/base/blocks/LinkListBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/layout/DashboardLayout.d.ts.map +1 -1
- package/dist-lib/base/partials/ConfirmationDialog/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/cell-renderers.d.ts +1 -1
- package/dist-lib/base/partials/DataTable/cell-renderers.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/sanitize-html.d.ts +17 -0
- package/dist-lib/base/partials/DataTable/sanitize-html.d.ts.map +1 -0
- package/dist-lib/base/partials/DataTable/types.d.ts +15 -0
- package/dist-lib/base/partials/DataTable/types.d.ts.map +1 -1
- package/dist-lib/base/partials/FilterBar/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +38 -24
- package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
- package/dist-lib/chunks/subpath-Bh1MAmBT.js +165 -0
- package/dist-lib/chunks/{subpath-AeMdleNB.js → subpath-fEhy6n_U.js} +10 -6
- package/dist-lib/contracts/block-data/data-display.d.ts +51 -2
- package/dist-lib/contracts/block-data/data-display.d.ts.map +1 -1
- package/dist-lib/contracts/generated/contract-schema.d.ts +1 -1
- package/dist-lib/contracts/generated/contract-types.d.ts +4 -2
- package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
- package/dist-lib/contracts/generated/index.d.ts +1 -1
- package/dist-lib/i18n/I18nProvider.js +1 -1
- package/dist-lib/i18n/instance.js +1 -1
- package/dist-lib/i18n/locales/en/ui.json +5 -3
- package/dist-lib/i18n/locales/pt-BR/ui.json +5 -3
- package/dist-lib/i18n/register-strings.js +1 -1
- package/dist-lib/index.d.ts +1 -1
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +18641 -13317
- package/dist-lib/primitives/reui/chart.d.ts.map +1 -1
- package/dist-lib/primitives/reui/chart.js +35 -31
- package/docs/public/schemas/ai-contract-manifest.json +1820 -0
- package/docs/public/schemas/blocks.json +445 -0
- package/docs/public/schemas/components.json +166 -0
- package/docs/public/schemas/connectors.json +97 -0
- package/docs/public/schemas/fragment.json +2329 -0
- package/docs/public/schemas/manifest.json +119 -0
- package/docs/public/schemas/navigation.json +72 -0
- package/docs/public/schemas/page-contract.json +2329 -0
- package/docs/public/schemas/shared-props.json +118 -0
- package/docs/public/schemas/theme-defaults.json +253 -0
- package/docs/public/schemas/theme.json +401 -0
- package/package.json +109 -3
- package/src/assets/lottie/calendar/schedule-1.json +1 -0
- package/src/assets/lottie/calendar/schedule-2.json +1 -0
- package/src/assets/lottie/celebration/confetti-1.json +1 -0
- package/src/assets/lottie/celebration/confetti-2.json +1 -0
- package/src/assets/lottie/celebration/confetti-3.json +1 -0
- package/src/assets/lottie/cloud/cloud-1.json +1 -0
- package/src/assets/lottie/cloud/cloud-2.json +1 -0
- package/src/assets/lottie/connection/network-1.json +1 -0
- package/src/assets/lottie/connection/network-2.json +1 -0
- package/src/assets/lottie/connection/network-3.json +1 -0
- package/src/assets/lottie/dashboard/analytics-1.json +1 -0
- package/src/assets/lottie/dashboard/analytics-2.json +1 -0
- package/src/assets/lottie/dashboard/analytics-3.json +1 -0
- package/src/assets/lottie/email/mail-1.json +1 -0
- package/src/assets/lottie/email/mail-2.json +1 -0
- package/src/assets/lottie/email/mail-3.json +1 -0
- package/src/assets/lottie/empty-state/empty-1.json +1 -0
- package/src/assets/lottie/empty-state/empty-2.json +1 -0
- package/src/assets/lottie/empty-state/empty-3.json +1 -0
- package/src/assets/lottie/error/warning-1.json +1 -0
- package/src/assets/lottie/error/warning-2.json +1 -0
- package/src/assets/lottie/error/warning-3.json +1 -0
- package/src/assets/lottie/index.ts +49 -0
- package/src/assets/lottie/loading/spinner-1.json +1 -0
- package/src/assets/lottie/loading/spinner-2.json +1 -0
- package/src/assets/lottie/loading/spinner-3.json +1 -0
- package/src/assets/lottie/maintenance/construction-1.json +1 -0
- package/src/assets/lottie/maintenance/construction-2.json +1 -0
- package/src/assets/lottie/maintenance/construction-3.json +1 -0
- package/src/assets/lottie/not-found/404-1.json +1 -0
- package/src/assets/lottie/not-found/404-2.json +1 -0
- package/src/assets/lottie/not-found/404-3.json +1 -0
- package/src/assets/lottie/notification/bell-1.json +1 -0
- package/src/assets/lottie/notification/bell-2.json +1 -0
- package/src/assets/lottie/notification/bell-3.json +1 -0
- package/src/assets/lottie/onboarding/welcome-1.json +1 -0
- package/src/assets/lottie/onboarding/welcome-2.json +1 -0
- package/src/assets/lottie/onboarding/welcome-3.json +1 -0
- package/src/assets/lottie/payment/wallet-1.json +1 -0
- package/src/assets/lottie/payment/wallet-2.json +1 -0
- package/src/assets/lottie/payment/wallet-3.json +1 -0
- package/src/assets/lottie/search/search-1.json +1 -0
- package/src/assets/lottie/search/search-2.json +1 -0
- package/src/assets/lottie/search/search-3.json +1 -0
- package/src/assets/lottie/security/lock-1.json +1 -0
- package/src/assets/lottie/security/lock-2.json +1 -0
- package/src/assets/lottie/security/lock-3.json +1 -0
- package/src/assets/lottie/settings/gear-1.json +1 -0
- package/src/assets/lottie/settings/gear-2.json +1 -0
- package/src/assets/lottie/settings/gear-3.json +1 -0
- package/src/assets/lottie/success/check-1.json +1 -0
- package/src/assets/lottie/success/check-2.json +1 -0
- package/src/assets/lottie/success/check-3.json +1 -0
- package/src/assets/lottie/upload/upload-1.json +1 -0
- package/src/assets/lottie/upload/upload-2.json +1 -0
- package/src/assets/lottie/upload/upload-3.json +1 -0
- package/src/assets/lottie/user/profile-1.json +1 -0
- package/src/assets/lottie/user/profile-2.json +1 -0
- package/src/assets/lottie/user/profile-3.json +1 -0
- package/src/base/blocks/ActionGridBlock.tsx +151 -0
- package/src/base/blocks/ActivityTimelineBlock.tsx +180 -0
- package/src/base/blocks/CardGridBlock.tsx +384 -0
- package/src/base/blocks/ChartBlock.tsx +81 -0
- package/src/base/blocks/DenseTableBlock.tsx +403 -0
- package/src/base/blocks/DetailPanelBlock.tsx +189 -0
- package/src/base/blocks/EmptyStateBlock.tsx +46 -0
- package/src/base/blocks/FormPanelBlock.lazy.tsx +38 -0
- package/src/base/blocks/FormPanelBlock.tsx +480 -0
- package/src/base/blocks/LinkListBlock.tsx +94 -0
- package/src/base/blocks/MarkdownPanelBlock.tsx +60 -0
- package/src/base/blocks/MetricCardBlock.tsx +128 -0
- package/src/base/blocks/StatusStripBlock.tsx +43 -0
- package/src/base/blocks/TabsBlock.tsx +94 -0
- package/src/base/form/FormField.tsx +607 -0
- package/src/base/form/fields/CheckboxField.tsx +56 -0
- package/src/base/form/fields/ColorField.tsx +76 -0
- package/src/base/form/fields/CurrencyField.tsx +126 -0
- package/src/base/form/fields/DateField.tsx +168 -0
- package/src/base/form/fields/DateRangeField.tsx +66 -0
- package/src/base/form/fields/DocumentField.tsx +222 -0
- package/src/base/form/fields/EntityPickerField.tsx +244 -0
- package/src/base/form/fields/FileUploadField.tsx +253 -0
- package/src/base/form/fields/MultiSelectField.tsx +286 -0
- package/src/base/form/fields/NativeSelectField.tsx +67 -0
- package/src/base/form/fields/NumberField.tsx +67 -0
- package/src/base/form/fields/OtpField.tsx +88 -0
- package/src/base/form/fields/PasswordField.tsx +69 -0
- package/src/base/form/fields/PhoneField.tsx +64 -0
- package/src/base/form/fields/RadioField.tsx +66 -0
- package/src/base/form/fields/RatingField.tsx +52 -0
- package/src/base/form/fields/SelectField.tsx +76 -0
- package/src/base/form/fields/SliderField.tsx +77 -0
- package/src/base/form/fields/SlugField.tsx +114 -0
- package/src/base/form/fields/StaticField.tsx +25 -0
- package/src/base/form/fields/SwitchField.tsx +56 -0
- package/src/base/form/fields/TagsField.tsx +128 -0
- package/src/base/form/fields/TextField.tsx +55 -0
- package/src/base/form/fields/TextareaField.tsx +55 -0
- package/src/base/form/fields/document-validation.ts +126 -0
- package/src/base/form/fields/field-registry.ts +53 -0
- package/src/base/form/fields/register-default-fields.ts +86 -0
- package/src/base/form/form-schema-builder.ts +192 -0
- package/src/base/form/form-utils.ts +71 -0
- package/src/base/hooks/useIsDark.ts +50 -0
- package/src/base/hooks/useLazyTabs.ts +98 -0
- package/src/base/hooks/usePolling.ts +43 -0
- package/src/base/hooks/useRemember.ts +58 -0
- package/src/base/hooks/useToast.ts +27 -0
- package/src/base/layout/BlockRegion.tsx +39 -0
- package/src/base/layout/DashboardLayout.tsx +110 -0
- package/src/base/layout/SidebarLayout.tsx +38 -0
- package/src/base/layout/StackLayout.tsx +32 -0
- package/src/base/layout/WizardLayout.tsx +49 -0
- package/src/base/partials/ActionBar/index.tsx +115 -0
- package/src/base/partials/ConfirmationDialog/index.tsx +128 -0
- package/src/base/partials/DataTable/cell-registry.ts +50 -0
- package/src/base/partials/DataTable/cell-renderers.tsx +372 -0
- package/src/base/partials/DataTable/index.tsx +1282 -0
- package/src/base/partials/DataTable/register-default-cells.ts +37 -0
- package/src/base/partials/DataTable/sanitize-html.ts +45 -0
- package/src/base/partials/DataTable/types.ts +229 -0
- package/src/base/partials/DetailSection/index.tsx +316 -0
- package/src/base/partials/EmptyPlaceholder/index.tsx +162 -0
- package/src/base/partials/EntityItem/index.tsx +154 -0
- package/src/base/partials/FilterBar/index.tsx +256 -0
- package/src/base/partials/FormSection/index.tsx +87 -0
- package/src/base/partials/LogViewer/JsonBlock.tsx +39 -0
- package/src/base/partials/LogViewer/LogEntry.tsx +68 -0
- package/src/base/partials/LogViewer/LogViewerToolbar.tsx +71 -0
- package/src/base/partials/LogViewer/index.tsx +110 -0
- package/src/base/partials/LogViewer/types.ts +28 -0
- package/src/base/partials/MarkdownContent/index.tsx +307 -0
- package/src/base/partials/MenuBar/index.tsx +80 -0
- package/src/base/partials/QuickRecordSheet/index.tsx +59 -0
- package/src/base/partials/ResizableSidebar/index.tsx +70 -0
- package/src/base/partials/StatRow/index.tsx +28 -0
- package/src/base/partials/StatusBar/index.tsx +126 -0
- package/src/base/partials/StatusIndicator/index.tsx +61 -0
- package/src/base/partials/StepIndicator/index.tsx +63 -0
- package/src/base/partials/TableOfContents/index.tsx +78 -0
- package/src/base/partials/TimelineList/index.tsx +273 -0
- package/src/base/partials/ToggleGroupControl/index.tsx +100 -0
- package/src/base/partials/TreeView/index.tsx +75 -0
- package/src/base/partials/index.ts +23 -0
- package/src/base/shell/AuthShell.tsx +54 -0
- package/src/base/shell/BasicShell.tsx +286 -0
- package/src/base/shell/ImmersiveShell.tsx +85 -0
- package/src/base/shell/partials/EditablePanelContext.tsx +82 -0
- package/src/base/shell/partials/EditablePanelProvider.tsx +122 -0
- package/src/base/shell/partials/InlineEditablePanel.tsx +239 -0
- package/src/base/shell/partials/InspectorContext.tsx +173 -0
- package/src/base/shell/partials/InspectorPanel.tsx +65 -0
- package/src/base/shell/partials/NavErrorBoundary.tsx +82 -0
- package/src/base/shell/partials/OverlayScreen.tsx +67 -0
- package/src/base/shell/partials/PageActionButton.tsx +203 -0
- package/src/base/theme/appearance.ts +133 -0
- package/src/base/theme/host-layout-detector.ts +119 -0
- package/src/base/theme/host-theme-detector.ts +146 -0
- package/src/base/theme/sidebar-safelist.txt +20 -0
- package/src/base/theme/tailwind-theme.css +136 -0
- package/src/base/theme/theme-bridge.css +164 -0
- package/src/base/theme/theme-context.tsx +142 -0
- package/src/base/theme/themes/classic.css +174 -0
- package/src/base/theme/tokens.css +290 -0
- package/src/base/theme/useHostTheme.ts +95 -0
- package/src/base/utils/clipboard.ts +39 -0
- package/src/base/utils/conditions.ts +27 -0
- package/src/base/utils/icon-registry.ts +78 -0
- package/src/base/utils/icons.ts +31 -0
- package/src/base/utils/interpolate.ts +9 -0
- package/src/base/utils/register-default-icons.ts +163 -0
- package/src/base/utils/storage.ts +65 -0
- package/src/base/utils/time.ts +139 -0
- package/src/contracts/block-data/actions.ts +73 -0
- package/src/contracts/block-data/data-display.ts +343 -0
- package/src/contracts/block-data/form.ts +164 -0
- package/src/contracts/block-data/index.ts +15 -0
- package/src/contracts/block-data/interactive.ts +34 -0
- package/src/contracts/block-data/shared.ts +44 -0
- package/src/contracts/connectors.ts +60 -0
- package/src/contracts/generated/contract-schema.ts +1237 -0
- package/src/contracts/generated/contract-types.ts +675 -0
- package/src/contracts/generated/index.ts +15 -0
- package/src/contracts/navigation.ts +59 -0
- package/src/contracts/page-contract-schema.ts +40 -0
- package/src/contracts/page-contract.ts +79 -0
- package/src/contracts/shared-props.ts +92 -0
- package/src/engine/ContractPage.tsx +178 -0
- package/src/engine/EntityRoutes.tsx +72 -0
- package/src/engine/HostSlot.tsx +126 -0
- package/src/engine/LazyBlock.tsx +92 -0
- package/src/engine/bootstrap.tsx +20 -0
- package/src/engine/providers/auth.tsx +87 -0
- package/src/engine/providers/error-reporter.tsx +89 -0
- package/src/engine/providers/flash.tsx +44 -0
- package/src/engine/providers/index.ts +18 -0
- package/src/engine/providers/inertia-error-reporter.tsx +61 -0
- package/src/engine/providers/progress.tsx +56 -0
- package/src/engine/providers/scope.tsx +51 -0
- package/src/engine/register-defaults.ts +88 -0
- package/src/engine/registries.ts +96 -0
- package/src/i18n/I18nProvider.tsx +53 -0
- package/src/i18n/MANIFEST.md +101 -0
- package/src/i18n/host-resolver.ts +18 -0
- package/src/i18n/instance.ts +69 -0
- package/src/i18n/locales/en/ui.json +277 -0
- package/src/i18n/locales/en/validators.json +13 -0
- package/src/i18n/locales/pt-BR/ui.json +277 -0
- package/src/i18n/locales/pt-BR/validators.json +13 -0
- package/src/i18n/register-strings.ts +10 -0
- package/src/i18n/render-label.ts +33 -0
- package/src/i18n/resolve-field-error.ts +29 -0
- package/src/i18n/useHostString.ts +50 -0
- package/src/i18n/useTranslation.ts +83 -0
- package/src/lib/actions/resolve-action-target.ts +151 -0
- package/src/lib/hooks/use-copy-to-clipboard.ts +37 -0
- package/src/lib/hooks/use-file-upload.ts +406 -0
- package/src/lib/hooks/use-mobile.ts +21 -0
- package/src/lib/host-pending.ts +76 -0
- package/src/lib/portal-container.ts +16 -0
- package/src/lib/test-ids.ts +40 -0
- package/src/lib/utils.ts +6 -0
- package/src/primitives/reui/MANIFEST.md +97 -0
- package/src/primitives/reui/accordion.tsx +64 -0
- package/src/primitives/reui/alert-dialog.tsx +196 -0
- package/src/primitives/reui/alert.tsx +92 -0
- package/src/primitives/reui/aspect-ratio.tsx +9 -0
- package/src/primitives/reui/autocomplete.tsx +343 -0
- package/src/primitives/reui/avatar.tsx +109 -0
- package/src/primitives/reui/badge.tsx +94 -0
- package/src/primitives/reui/breadcrumb.tsx +109 -0
- package/src/primitives/reui/button-group.tsx +83 -0
- package/src/primitives/reui/button.tsx +64 -0
- package/src/primitives/reui/calendar.tsx +220 -0
- package/src/primitives/reui/card.tsx +92 -0
- package/src/primitives/reui/carousel.tsx +239 -0
- package/src/primitives/reui/chart.tsx +388 -0
- package/src/primitives/reui/checkbox.tsx +30 -0
- package/src/primitives/reui/collapsible.tsx +31 -0
- package/src/primitives/reui/combobox.tsx +308 -0
- package/src/primitives/reui/command.tsx +182 -0
- package/src/primitives/reui/context-menu.tsx +250 -0
- package/src/primitives/reui/data-grid/data-grid-column-filter.tsx +172 -0
- package/src/primitives/reui/data-grid/data-grid-column-header.tsx +420 -0
- package/src/primitives/reui/data-grid/data-grid-column-visibility.tsx +51 -0
- package/src/primitives/reui/data-grid/data-grid-pagination.tsx +235 -0
- package/src/primitives/reui/data-grid/data-grid-scroll-area.tsx +427 -0
- package/src/primitives/reui/data-grid/data-grid-table-dnd-rows.tsx +308 -0
- package/src/primitives/reui/data-grid/data-grid-table-dnd.tsx +318 -0
- package/src/primitives/reui/data-grid/data-grid-table-virtual.tsx +491 -0
- package/src/primitives/reui/data-grid/data-grid-table.tsx +1430 -0
- package/src/primitives/reui/data-grid/data-grid.tsx +269 -0
- package/src/primitives/reui/data-grid-pagination.tsx +235 -0
- package/src/primitives/reui/date-selector.tsx +1353 -0
- package/src/primitives/reui/dialog.tsx +158 -0
- package/src/primitives/reui/drawer.tsx +133 -0
- package/src/primitives/reui/dropdown-menu.tsx +257 -0
- package/src/primitives/reui/empty.tsx +104 -0
- package/src/primitives/reui/field.tsx +246 -0
- package/src/primitives/reui/filters.tsx +1891 -0
- package/src/primitives/reui/frame.tsx +170 -0
- package/src/primitives/reui/hover-card.tsx +42 -0
- package/src/primitives/reui/icon-placeholder.tsx +39 -0
- package/src/primitives/reui/index.ts +98 -0
- package/src/primitives/reui/input-group.tsx +170 -0
- package/src/primitives/reui/input-otp.tsx +75 -0
- package/src/primitives/reui/input.tsx +21 -0
- package/src/primitives/reui/item.tsx +193 -0
- package/src/primitives/reui/kanban.tsx +743 -0
- package/src/primitives/reui/kbd.tsx +28 -0
- package/src/primitives/reui/label.tsx +22 -0
- package/src/primitives/reui/menubar.tsx +274 -0
- package/src/primitives/reui/native-select.tsx +62 -0
- package/src/primitives/reui/navigation-menu.tsx +168 -0
- package/src/primitives/reui/number-field.tsx +250 -0
- package/src/primitives/reui/pagination.tsx +127 -0
- package/src/primitives/reui/phone-input.tsx +231 -0
- package/src/primitives/reui/popover.tsx +87 -0
- package/src/primitives/reui/progress.tsx +31 -0
- package/src/primitives/reui/radio-group.tsx +43 -0
- package/src/primitives/reui/rating.tsx +177 -0
- package/src/primitives/reui/resizable.tsx +51 -0
- package/src/primitives/reui/scroll-area.tsx +58 -0
- package/src/primitives/reui/scrollspy.tsx +240 -0
- package/src/primitives/reui/select.tsx +188 -0
- package/src/primitives/reui/separator.tsx +28 -0
- package/src/primitives/reui/sheet.tsx +141 -0
- package/src/primitives/reui/sidebar.tsx +732 -0
- package/src/primitives/reui/skeleton.tsx +13 -0
- package/src/primitives/reui/slider.tsx +61 -0
- package/src/primitives/reui/sonner.tsx +47 -0
- package/src/primitives/reui/sortable.tsx +414 -0
- package/src/primitives/reui/spinner.tsx +16 -0
- package/src/primitives/reui/stepper.tsx +484 -0
- package/src/primitives/reui/svgs/claudeAiIcon.tsx +12 -0
- package/src/primitives/reui/svgs/gemini.tsx +171 -0
- package/src/primitives/reui/svgs/openai.tsx +9 -0
- package/src/primitives/reui/svgs/openaiDark.tsx +12 -0
- package/src/primitives/reui/switch.tsx +33 -0
- package/src/primitives/reui/table.tsx +114 -0
- package/src/primitives/reui/tabs.tsx +91 -0
- package/src/primitives/reui/textarea.tsx +18 -0
- package/src/primitives/reui/timeline.tsx +219 -0
- package/src/primitives/reui/toggle-group.tsx +83 -0
- package/src/primitives/reui/toggle.tsx +45 -0
- package/src/primitives/reui/tooltip.tsx +55 -0
- package/src/primitives/reui/tree.tsx +247 -0
- package/src/theme.css +71 -0
- package/dist-lib/chunks/subpath-q4Q2zg_p.js +0 -153
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MetricCardBlock — KPI card with value, delta, icon, and optional link.
|
|
3
|
+
*
|
|
4
|
+
* @see NV-05-ux-blocks.md §3.1–3.7
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ReactElement } from "react";
|
|
8
|
+
import { ArrowDown01Icon, ArrowUp01Icon } from "@hugeicons/core-free-icons";
|
|
9
|
+
import { HugeiconsIcon } from "@hugeicons/react";
|
|
10
|
+
import { Link } from "@inertiajs/react";
|
|
11
|
+
|
|
12
|
+
import { getIcon } from "@/base/utils/icons";
|
|
13
|
+
import type { MetricCardBlockData } from "@/contracts/block-data";
|
|
14
|
+
import type { BlockProps } from "@/engine/registries";
|
|
15
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
16
|
+
import { cn } from "@/lib/utils";
|
|
17
|
+
import { Card, CardContent, CardHeader } from "@/primitives/reui/card";
|
|
18
|
+
import { Skeleton } from "@/primitives/reui/skeleton";
|
|
19
|
+
import {
|
|
20
|
+
Tooltip,
|
|
21
|
+
TooltipContent,
|
|
22
|
+
TooltipProvider,
|
|
23
|
+
TooltipTrigger,
|
|
24
|
+
} from "@/primitives/reui/tooltip";
|
|
25
|
+
|
|
26
|
+
function inferDeltaDirection(
|
|
27
|
+
delta?: string,
|
|
28
|
+
explicit?: "positive" | "negative" | "neutral",
|
|
29
|
+
): "positive" | "negative" | "neutral" {
|
|
30
|
+
if (explicit) return explicit;
|
|
31
|
+
if (!delta) return "neutral";
|
|
32
|
+
if (delta.startsWith("+") || delta.startsWith("↑")) return "positive";
|
|
33
|
+
if (delta.startsWith("-") || delta.startsWith("↓")) return "negative";
|
|
34
|
+
return "neutral";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function formatValue(value: string | number, locale = "pt-BR", compact = false): string {
|
|
38
|
+
if (typeof value === "string") return value;
|
|
39
|
+
if (compact || value >= 100_000) {
|
|
40
|
+
return new Intl.NumberFormat(locale, { notation: "compact" }).format(value);
|
|
41
|
+
}
|
|
42
|
+
return new Intl.NumberFormat(locale).format(value);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const DELTA_STYLES = {
|
|
46
|
+
positive: "text-success",
|
|
47
|
+
negative: "text-destructive",
|
|
48
|
+
neutral: "text-muted-foreground",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export function MetricCardBlock({ block }: BlockProps<MetricCardBlockData>): ReactElement {
|
|
52
|
+
const { t } = useTranslation();
|
|
53
|
+
const { data, meta } = block;
|
|
54
|
+
const isLoading = meta?.loading === true;
|
|
55
|
+
const direction = inferDeltaDirection(data.delta, data.deltaDirection);
|
|
56
|
+
|
|
57
|
+
if (isLoading) {
|
|
58
|
+
return (
|
|
59
|
+
<Card>
|
|
60
|
+
<CardHeader className="pb-2">
|
|
61
|
+
<Skeleton className="h-5 w-5 rounded" />
|
|
62
|
+
</CardHeader>
|
|
63
|
+
<CardContent className="space-y-2">
|
|
64
|
+
<Skeleton className="h-8 w-24" />
|
|
65
|
+
<Skeleton className="h-3 w-12" />
|
|
66
|
+
<Skeleton className="h-4 w-32" />
|
|
67
|
+
</CardContent>
|
|
68
|
+
</Card>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const formattedValue = formatValue(data.value, data.locale, data.compact);
|
|
73
|
+
|
|
74
|
+
const cardContent = (
|
|
75
|
+
<Card
|
|
76
|
+
className={cn(
|
|
77
|
+
"gap-3 py-4 transition-shadow duration-150",
|
|
78
|
+
data.href && "hover:bg-accent/50 cursor-pointer hover:shadow-sm",
|
|
79
|
+
)}
|
|
80
|
+
>
|
|
81
|
+
<CardHeader className="pb-0">
|
|
82
|
+
{data.icon && (
|
|
83
|
+
<HugeiconsIcon icon={getIcon(data.icon)} size={18} className="text-muted-foreground" />
|
|
84
|
+
)}
|
|
85
|
+
</CardHeader>
|
|
86
|
+
<CardContent>
|
|
87
|
+
<p className="text-muted-foreground text-xs">{data.label}</p>
|
|
88
|
+
<p className="text-foreground text-2xl leading-tight font-bold tabular-nums">
|
|
89
|
+
{formattedValue}
|
|
90
|
+
</p>
|
|
91
|
+
{data.delta && (
|
|
92
|
+
<p className={cn("mt-1 flex items-center gap-1 text-xs", DELTA_STYLES[direction])}>
|
|
93
|
+
{direction === "positive" && <HugeiconsIcon icon={ArrowUp01Icon} size={12} />}
|
|
94
|
+
{direction === "negative" && <HugeiconsIcon icon={ArrowDown01Icon} size={12} />}
|
|
95
|
+
{data.delta}
|
|
96
|
+
</p>
|
|
97
|
+
)}
|
|
98
|
+
</CardContent>
|
|
99
|
+
</Card>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
if (data.href) {
|
|
103
|
+
const ariaLabel =
|
|
104
|
+
direction === "neutral"
|
|
105
|
+
? t("middag.ui.metric.aria_value", { label: data.label, value: formattedValue })
|
|
106
|
+
: t(
|
|
107
|
+
direction === "positive"
|
|
108
|
+
? "middag.ui.metric.aria_increase"
|
|
109
|
+
: "middag.ui.metric.aria_decrease",
|
|
110
|
+
{ label: data.label, value: formattedValue, delta: data.delta },
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<TooltipProvider>
|
|
115
|
+
<Tooltip>
|
|
116
|
+
<TooltipTrigger asChild>
|
|
117
|
+
<Link href={data.href} aria-label={ariaLabel}>
|
|
118
|
+
{cardContent}
|
|
119
|
+
</Link>
|
|
120
|
+
</TooltipTrigger>
|
|
121
|
+
<TooltipContent>{t("middag.ui.metric.view_details")}</TooltipContent>
|
|
122
|
+
</Tooltip>
|
|
123
|
+
</TooltipProvider>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return cardContent;
|
|
128
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusStripBlock — horizontal status indicators strip.
|
|
3
|
+
*
|
|
4
|
+
* Delegates to StatusBar partial. Derives score item if score is present.
|
|
5
|
+
*
|
|
6
|
+
* @see NV-05-ux-blocks.md §5
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ReactElement } from "react";
|
|
10
|
+
|
|
11
|
+
import { StatusBar, type StatusBarItem } from "@/base/partials/StatusBar";
|
|
12
|
+
import type { StatusItemAppearance, StatusStripBlockData } from "@/contracts/block-data";
|
|
13
|
+
import type { BlockProps } from "@/engine/registries";
|
|
14
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
15
|
+
|
|
16
|
+
function scoreToAppearance(score: number): StatusItemAppearance {
|
|
17
|
+
if (score >= 80) return "success";
|
|
18
|
+
if (score >= 60) return "warning";
|
|
19
|
+
return "danger";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function StatusStripBlock({ block }: BlockProps<StatusStripBlockData>): ReactElement | null {
|
|
23
|
+
const { t } = useTranslation();
|
|
24
|
+
const { data, meta } = block;
|
|
25
|
+
const isLoading = meta?.loading === true;
|
|
26
|
+
|
|
27
|
+
const items: StatusBarItem[] = [];
|
|
28
|
+
|
|
29
|
+
if (data.score !== undefined) {
|
|
30
|
+
items.push({
|
|
31
|
+
key: "__score",
|
|
32
|
+
label: t("middag.ui.status.score"),
|
|
33
|
+
value: `${data.score}%`,
|
|
34
|
+
appearance: scoreToAppearance(data.score),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
items.push(...data.items);
|
|
39
|
+
|
|
40
|
+
if (items.length === 0 && !isLoading) return null;
|
|
41
|
+
|
|
42
|
+
return <StatusBar items={items} isLoading={isLoading} />;
|
|
43
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TabsBlock — composite block that organizes inner blocks into tabs.
|
|
3
|
+
*
|
|
4
|
+
* Each tab contains an array of BlockDescriptors rendered via the block registry.
|
|
5
|
+
* Uses ReUI Tabs with line variant + MIDDAG-specific styling (2px primary underline,
|
|
6
|
+
* active font-weight 500).
|
|
7
|
+
*
|
|
8
|
+
* @see DESIGN.md §P1 — Tabs
|
|
9
|
+
* @see ADR-807 ref/page-contract-v1 §5
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ReactElement } from "react";
|
|
13
|
+
|
|
14
|
+
import { NavErrorBoundary } from "@/base/shell/partials/NavErrorBoundary";
|
|
15
|
+
import type { TabsBlockData } from "@/contracts/block-data";
|
|
16
|
+
import type { BlockDescriptor } from "@/contracts/page-contract";
|
|
17
|
+
import { isLazyBlock, LazyBlock } from "@/engine/LazyBlock";
|
|
18
|
+
import { resolveBlock } from "@/engine/registries";
|
|
19
|
+
import type { BlockProps } from "@/engine/registries";
|
|
20
|
+
import { renderLabel } from "@/i18n/render-label";
|
|
21
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
22
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/primitives/reui/tabs";
|
|
23
|
+
|
|
24
|
+
function UnknownBlock({ type }: { type: string }): ReactElement {
|
|
25
|
+
const { t } = useTranslation();
|
|
26
|
+
return (
|
|
27
|
+
<div className="border-border text-muted-foreground rounded-md border border-dashed p-2 text-sm">
|
|
28
|
+
{t("middag.ui.block.unknown_type")}{" "}
|
|
29
|
+
<code className="bg-muted rounded-[3px] px-1.5 py-px font-mono text-xs">{type}</code>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function renderInnerBlock(block: BlockDescriptor): ReactElement | null {
|
|
35
|
+
const Block = resolveBlock(block.type);
|
|
36
|
+
|
|
37
|
+
if (!Block) {
|
|
38
|
+
return <UnknownBlock key={block.key} type={block.type} />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isLazyBlock(block)) {
|
|
42
|
+
return (
|
|
43
|
+
<NavErrorBoundary key={block.key}>
|
|
44
|
+
<LazyBlock block={block} Component={Block} />
|
|
45
|
+
</NavErrorBoundary>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<NavErrorBoundary key={block.key}>
|
|
51
|
+
<Block block={block} />
|
|
52
|
+
</NavErrorBoundary>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function TabsBlock({ block }: BlockProps<TabsBlockData>): ReactElement {
|
|
57
|
+
const { t } = useTranslation();
|
|
58
|
+
const { tabs, defaultTab } = block.data;
|
|
59
|
+
|
|
60
|
+
if (tabs.length === 0) {
|
|
61
|
+
return <div />;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const initialTab = defaultTab ?? tabs[0].id;
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<Tabs defaultValue={initialTab} className="w-full">
|
|
68
|
+
<TabsList variant="line" className="border-border w-full justify-start border-b">
|
|
69
|
+
{tabs.map((tab) => (
|
|
70
|
+
<TabsTrigger
|
|
71
|
+
key={tab.id}
|
|
72
|
+
value={tab.id}
|
|
73
|
+
disabled={tab.disabled ?? false}
|
|
74
|
+
className="data-[state=active]:text-primary data-[state=active]:after:bg-primary px-4 py-3 text-sm disabled:pointer-events-none disabled:opacity-50 data-[state=active]:font-medium"
|
|
75
|
+
>
|
|
76
|
+
{renderLabel(tab.label, t)}
|
|
77
|
+
</TabsTrigger>
|
|
78
|
+
))}
|
|
79
|
+
</TabsList>
|
|
80
|
+
|
|
81
|
+
{tabs.map((tab) => (
|
|
82
|
+
<TabsContent key={tab.id} value={tab.id} className="mt-4 space-y-6">
|
|
83
|
+
{/* tab.blocks is the generated wire BlockDescriptor (data: object | []);
|
|
84
|
+
renderInnerBlock takes the composed page-contract BlockDescriptor
|
|
85
|
+
(data: Record<string, unknown>). Same runtime JSON shape — the
|
|
86
|
+
generated union's `[]` arm only exists for the empty-object wire
|
|
87
|
+
case, which is not representable as Record<string, unknown> at
|
|
88
|
+
the type level. */}
|
|
89
|
+
{(tab.blocks as unknown as BlockDescriptor[]).map(renderInnerBlock)}
|
|
90
|
+
</TabsContent>
|
|
91
|
+
))}
|
|
92
|
+
</Tabs>
|
|
93
|
+
);
|
|
94
|
+
}
|