@middag-io/react 0.45.0 → 0.45.3
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 +4 -3
- 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
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuickRecordSheet — slide-over panel for quick record create/edit.
|
|
3
|
+
*
|
|
4
|
+
* Community partial built on the ReUI Sheet (Radix Dialog) primitive. Controlled
|
|
5
|
+
* via `open`/`onOpenChange`; the caller supplies the form body (children) and the
|
|
6
|
+
* action footer. Holds no data and fetches nothing.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
Sheet,
|
|
13
|
+
SheetContent,
|
|
14
|
+
SheetDescription,
|
|
15
|
+
SheetFooter,
|
|
16
|
+
SheetHeader,
|
|
17
|
+
SheetTitle,
|
|
18
|
+
SheetTrigger,
|
|
19
|
+
} from "@/primitives/reui/sheet";
|
|
20
|
+
|
|
21
|
+
export interface QuickRecordSheetProps {
|
|
22
|
+
open: boolean;
|
|
23
|
+
onOpenChange: (open: boolean) => void;
|
|
24
|
+
title: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
/** Form body. */
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
/** Action footer (e.g. save / cancel buttons). */
|
|
29
|
+
footer?: ReactNode;
|
|
30
|
+
/** Which edge the sheet slides in from. Default "right". */
|
|
31
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
32
|
+
/** Optional trigger element rendered inline (uses asChild). */
|
|
33
|
+
trigger?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function QuickRecordSheet({
|
|
37
|
+
open,
|
|
38
|
+
onOpenChange,
|
|
39
|
+
title,
|
|
40
|
+
description,
|
|
41
|
+
children,
|
|
42
|
+
footer,
|
|
43
|
+
side = "right",
|
|
44
|
+
trigger,
|
|
45
|
+
}: QuickRecordSheetProps): ReactElement {
|
|
46
|
+
return (
|
|
47
|
+
<Sheet open={open} onOpenChange={onOpenChange}>
|
|
48
|
+
{trigger && <SheetTrigger asChild>{trigger}</SheetTrigger>}
|
|
49
|
+
<SheetContent side={side} className="sm:max-w-md">
|
|
50
|
+
<SheetHeader>
|
|
51
|
+
<SheetTitle>{title}</SheetTitle>
|
|
52
|
+
{description && <SheetDescription>{description}</SheetDescription>}
|
|
53
|
+
</SheetHeader>
|
|
54
|
+
<div className="flex-1 overflow-y-auto px-4">{children}</div>
|
|
55
|
+
{footer && <SheetFooter>{footer}</SheetFooter>}
|
|
56
|
+
</SheetContent>
|
|
57
|
+
</Sheet>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResizableSidebar — a content area with a user-resizable aside panel.
|
|
3
|
+
*
|
|
4
|
+
* Community shell primitive built on the ReUI Resizable (react-resizable-panels)
|
|
5
|
+
* primitive. Holds no data and fetches nothing — the caller supplies both the
|
|
6
|
+
* main content and the aside content.
|
|
7
|
+
*
|
|
8
|
+
* The richer data-driven InlineInspector composition lives in @middag-io/react-pro.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
12
|
+
|
|
13
|
+
import { cn } from "@/lib/utils";
|
|
14
|
+
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@/primitives/reui/resizable";
|
|
15
|
+
|
|
16
|
+
export interface ResizableSidebarProps {
|
|
17
|
+
/** Primary content. */
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
/** Aside (secondary) content. */
|
|
20
|
+
aside: ReactNode;
|
|
21
|
+
/** Which side the aside sits on. Default "right". */
|
|
22
|
+
asideSide?: "left" | "right";
|
|
23
|
+
/** Initial aside width as a percentage of the group. Default 30. */
|
|
24
|
+
defaultAsideSize?: number;
|
|
25
|
+
/** Minimum aside width percentage. Default 15. */
|
|
26
|
+
minAsideSize?: number;
|
|
27
|
+
/** Maximum aside width percentage. Default 50. */
|
|
28
|
+
maxAsideSize?: number;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function ResizableSidebar({
|
|
33
|
+
children,
|
|
34
|
+
aside,
|
|
35
|
+
asideSide = "right",
|
|
36
|
+
defaultAsideSize = 30,
|
|
37
|
+
minAsideSize = 15,
|
|
38
|
+
maxAsideSize = 50,
|
|
39
|
+
className,
|
|
40
|
+
}: ResizableSidebarProps): ReactElement {
|
|
41
|
+
const mainPanel = (
|
|
42
|
+
<ResizablePanel defaultSize={100 - defaultAsideSize} minSize={100 - maxAsideSize}>
|
|
43
|
+
{children}
|
|
44
|
+
</ResizablePanel>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const asidePanel = (
|
|
48
|
+
<ResizablePanel defaultSize={defaultAsideSize} minSize={minAsideSize} maxSize={maxAsideSize}>
|
|
49
|
+
{aside}
|
|
50
|
+
</ResizablePanel>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ResizablePanelGroup orientation="horizontal" className={cn("h-full", className)}>
|
|
55
|
+
{asideSide === "left" ? (
|
|
56
|
+
<>
|
|
57
|
+
{asidePanel}
|
|
58
|
+
<ResizableHandle withHandle />
|
|
59
|
+
{mainPanel}
|
|
60
|
+
</>
|
|
61
|
+
) : (
|
|
62
|
+
<>
|
|
63
|
+
{mainPanel}
|
|
64
|
+
<ResizableHandle withHandle />
|
|
65
|
+
{asidePanel}
|
|
66
|
+
</>
|
|
67
|
+
)}
|
|
68
|
+
</ResizablePanelGroup>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatRow — responsive grid container for MetricCardBlock instances.
|
|
3
|
+
*
|
|
4
|
+
* @see NV-05-ux-screens-core.md T-01 metrics region
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ReactElement, ReactNode } from "react";
|
|
8
|
+
|
|
9
|
+
import { cn } from "@/lib/utils";
|
|
10
|
+
|
|
11
|
+
export interface StatRowProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
columns?: 2 | 3 | 4;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const COLUMN_CLASSES: Record<number, string> = {
|
|
17
|
+
2: "grid-cols-1 sm:grid-cols-2",
|
|
18
|
+
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",
|
|
19
|
+
4: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-4",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export function StatRow({ children, columns }: StatRowProps): ReactElement {
|
|
23
|
+
const gridClass = columns
|
|
24
|
+
? COLUMN_CLASSES[columns]
|
|
25
|
+
: "grid-cols-[repeat(auto-fit,minmax(200px,1fr))]";
|
|
26
|
+
|
|
27
|
+
return <div className={cn("grid gap-6", gridClass)}>{children}</div>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusBar — horizontal strip of status indicators with colored dots.
|
|
3
|
+
*
|
|
4
|
+
* @see NV-05-ux-blocks.md §5.1–5.8
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ReactElement } from "react";
|
|
8
|
+
|
|
9
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
10
|
+
import { cn } from "@/lib/utils";
|
|
11
|
+
import { Skeleton } from "@/primitives/reui/skeleton";
|
|
12
|
+
import {
|
|
13
|
+
Tooltip,
|
|
14
|
+
TooltipContent,
|
|
15
|
+
TooltipProvider,
|
|
16
|
+
TooltipTrigger,
|
|
17
|
+
} from "@/primitives/reui/tooltip";
|
|
18
|
+
|
|
19
|
+
export type StatusAppearance = "success" | "warning" | "danger" | "info" | "neutral";
|
|
20
|
+
|
|
21
|
+
export interface StatusBarItem {
|
|
22
|
+
key: string;
|
|
23
|
+
label: string;
|
|
24
|
+
value: string;
|
|
25
|
+
appearance: StatusAppearance;
|
|
26
|
+
tooltip?: string;
|
|
27
|
+
href?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface StatusBarProps {
|
|
31
|
+
items: StatusBarItem[];
|
|
32
|
+
isLoading?: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const DOT_COLORS: Record<StatusAppearance, string> = {
|
|
36
|
+
success: "bg-success",
|
|
37
|
+
warning: "bg-warning",
|
|
38
|
+
danger: "bg-destructive",
|
|
39
|
+
info: "bg-info",
|
|
40
|
+
neutral: "bg-muted-foreground",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
function StatusBarItemComponent({ item }: { item: StatusBarItem }): ReactElement {
|
|
44
|
+
const { t } = useTranslation();
|
|
45
|
+
const content = (
|
|
46
|
+
<span
|
|
47
|
+
className="flex items-center gap-2"
|
|
48
|
+
aria-label={t("middag.ui.status.item", {
|
|
49
|
+
label: item.label,
|
|
50
|
+
value: item.value,
|
|
51
|
+
appearance: t(`middag.ui.status.appearance_${item.appearance}`),
|
|
52
|
+
})}
|
|
53
|
+
>
|
|
54
|
+
<span
|
|
55
|
+
className={cn("h-2 w-2 shrink-0 rounded-full", DOT_COLORS[item.appearance])}
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
/>
|
|
58
|
+
<span className="text-muted-foreground text-xs">{item.label}</span>
|
|
59
|
+
<span className="text-sm font-semibold">{item.value}</span>
|
|
60
|
+
</span>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (item.tooltip) {
|
|
64
|
+
return (
|
|
65
|
+
<TooltipProvider>
|
|
66
|
+
<Tooltip>
|
|
67
|
+
<TooltipTrigger asChild>
|
|
68
|
+
{item.href ? (
|
|
69
|
+
<a
|
|
70
|
+
href={item.href}
|
|
71
|
+
className="hover:bg-accent/50 rounded-md px-2 py-1 transition-colors"
|
|
72
|
+
>
|
|
73
|
+
{content}
|
|
74
|
+
</a>
|
|
75
|
+
) : (
|
|
76
|
+
<span className="px-2 py-1">{content}</span>
|
|
77
|
+
)}
|
|
78
|
+
</TooltipTrigger>
|
|
79
|
+
<TooltipContent>{item.tooltip}</TooltipContent>
|
|
80
|
+
</Tooltip>
|
|
81
|
+
</TooltipProvider>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (item.href) {
|
|
86
|
+
return (
|
|
87
|
+
<a href={item.href} className="hover:bg-accent/50 rounded-md px-2 py-1 transition-colors">
|
|
88
|
+
{content}
|
|
89
|
+
</a>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return <span className="px-2 py-1">{content}</span>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function StatusBar({ items, isLoading }: StatusBarProps): ReactElement | null {
|
|
97
|
+
const { t } = useTranslation();
|
|
98
|
+
if (isLoading) {
|
|
99
|
+
return (
|
|
100
|
+
<div className="flex flex-wrap gap-4" role="status" aria-label={t("middag.ui.status.system")}>
|
|
101
|
+
{[1, 2, 3, 4].map((i) => (
|
|
102
|
+
<Skeleton key={i} className={cn("h-4", i % 2 === 0 ? "w-28" : "w-20")} />
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (items.length === 0) return null;
|
|
109
|
+
|
|
110
|
+
const allDanger = items.every((item) => item.appearance === "danger");
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div
|
|
114
|
+
role="status"
|
|
115
|
+
aria-label={t("middag.ui.status.system")}
|
|
116
|
+
className={cn(
|
|
117
|
+
"flex flex-wrap gap-4",
|
|
118
|
+
allDanger && "border-destructive/20 bg-destructive-subtle/20 rounded-md border p-2",
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{items.map((item) => (
|
|
122
|
+
<StatusBarItemComponent key={item.key} item={item} />
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatusIndicator — colored dot/icon with optional label.
|
|
3
|
+
*
|
|
4
|
+
* Used by DataTable status cells, detail panels, and anywhere status display is needed.
|
|
5
|
+
*
|
|
6
|
+
* @see NV-05-ux-blocks.md §1.2
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { ReactElement } from "react";
|
|
10
|
+
|
|
11
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
12
|
+
import { cn } from "@/lib/utils";
|
|
13
|
+
|
|
14
|
+
export type IndicatorSize = "sm" | "md";
|
|
15
|
+
|
|
16
|
+
export interface StatusIndicatorProps {
|
|
17
|
+
status: string;
|
|
18
|
+
label?: string;
|
|
19
|
+
size?: IndicatorSize;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const STATUS_COLORS: Record<string, string> = {
|
|
23
|
+
connected: "bg-success",
|
|
24
|
+
active: "bg-success",
|
|
25
|
+
healthy: "bg-success",
|
|
26
|
+
success: "bg-success",
|
|
27
|
+
degraded: "bg-warning",
|
|
28
|
+
warning: "bg-warning",
|
|
29
|
+
pending: "bg-warning",
|
|
30
|
+
disconnected: "bg-destructive",
|
|
31
|
+
failed: "bg-destructive",
|
|
32
|
+
error: "bg-destructive",
|
|
33
|
+
inactive: "bg-muted-foreground",
|
|
34
|
+
unknown: "bg-muted-foreground",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function getStatusColor(status: string): string {
|
|
38
|
+
return STATUS_COLORS[status.toLowerCase()] ?? "bg-muted-foreground";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function StatusIndicator({
|
|
42
|
+
status,
|
|
43
|
+
label,
|
|
44
|
+
size = "sm",
|
|
45
|
+
}: StatusIndicatorProps): ReactElement {
|
|
46
|
+
const { t } = useTranslation();
|
|
47
|
+
const dotSize = size === "sm" ? "h-2 w-2" : "h-4 w-4";
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<span
|
|
51
|
+
className="inline-flex items-center gap-2"
|
|
52
|
+
aria-label={t("middag.ui.status.label", { value: label ?? status })}
|
|
53
|
+
>
|
|
54
|
+
<span
|
|
55
|
+
className={cn("shrink-0 rounded-full", dotSize, getStatusColor(status))}
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
/>
|
|
58
|
+
{label && <span className="text-foreground text-sm">{label}</span>}
|
|
59
|
+
</span>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StepIndicator — horizontal step progress bar for WizardLayout.
|
|
3
|
+
*
|
|
4
|
+
* Wraps ReUI Stepper in a read-only mode with server-driven step data.
|
|
5
|
+
* Step data comes from layout.meta.steps (server-driven).
|
|
6
|
+
*
|
|
7
|
+
* Keyboard navigation is handled by ReUI Stepper (arrow keys, Home/End).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ReactElement } from "react";
|
|
11
|
+
import { CheckmarkCircle02Icon } from "@hugeicons/core-free-icons";
|
|
12
|
+
import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
Stepper,
|
|
16
|
+
StepperIndicator,
|
|
17
|
+
StepperItem,
|
|
18
|
+
StepperSeparator,
|
|
19
|
+
StepperTitle,
|
|
20
|
+
} from "@/primitives/reui/stepper";
|
|
21
|
+
|
|
22
|
+
export interface StepItem {
|
|
23
|
+
label: string;
|
|
24
|
+
status: "completed" | "active" | "pending";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function StepIndicator({ steps }: { steps: StepItem[] }): ReactElement {
|
|
28
|
+
// Find the 1-based index of the active step (ReUI Stepper uses 1-based)
|
|
29
|
+
const activeIndex = steps.findIndex((s) => s.status === "active") + 1 || 1;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Stepper
|
|
33
|
+
value={activeIndex}
|
|
34
|
+
orientation="horizontal"
|
|
35
|
+
className="flex items-center justify-center"
|
|
36
|
+
indicators={{
|
|
37
|
+
completed: (
|
|
38
|
+
<HugeiconsIcon
|
|
39
|
+
icon={CheckmarkCircle02Icon as unknown as IconSvgElement}
|
|
40
|
+
className="size-4"
|
|
41
|
+
/>
|
|
42
|
+
),
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
{steps.map((step, index) => (
|
|
46
|
+
<StepperItem
|
|
47
|
+
key={step.label}
|
|
48
|
+
step={index + 1}
|
|
49
|
+
completed={step.status === "completed"}
|
|
50
|
+
loading={false}
|
|
51
|
+
disabled={step.status === "pending"}
|
|
52
|
+
className="flex items-center"
|
|
53
|
+
>
|
|
54
|
+
<div className="flex flex-col items-center gap-1.5">
|
|
55
|
+
<StepperIndicator />
|
|
56
|
+
<StepperTitle className="text-xs whitespace-nowrap">{step.label}</StepperTitle>
|
|
57
|
+
</div>
|
|
58
|
+
{index < steps.length - 1 && <StepperSeparator className="mx-3" />}
|
|
59
|
+
</StepperItem>
|
|
60
|
+
))}
|
|
61
|
+
</Stepper>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TableOfContents — anchor navigation for long content (DetailPanel, Markdown).
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper over the ReUI Scrollspy primitive: renders a nav of anchor links
|
|
5
|
+
* that highlight the section currently in view and scroll-to on click. The caller
|
|
6
|
+
* supplies the heading list (already translated) and a ref to the scroll container
|
|
7
|
+
* whose sections carry matching `id` attributes.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { type ReactElement, type RefObject } from "react";
|
|
11
|
+
|
|
12
|
+
import { useTranslation } from "@/i18n/useTranslation";
|
|
13
|
+
import { cn } from "@/lib/utils";
|
|
14
|
+
import { Scrollspy } from "@/primitives/reui/scrollspy";
|
|
15
|
+
|
|
16
|
+
export interface TableOfContentsItem {
|
|
17
|
+
/** Anchor id — must match the `id` of the target section element. */
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/** Heading level for indentation (2 = top-level, 3/4 = nested). Default 2. */
|
|
21
|
+
level?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface TableOfContentsProps {
|
|
25
|
+
items: TableOfContentsItem[];
|
|
26
|
+
/** Ref to the scrollable container holding the sections. Omit to track the document. */
|
|
27
|
+
targetRef?: RefObject<HTMLElement | null>;
|
|
28
|
+
/** Pixel offset applied when detecting/scrolling to a section. */
|
|
29
|
+
offset?: number;
|
|
30
|
+
/** Sync the active section to the URL hash. Default true. */
|
|
31
|
+
history?: boolean;
|
|
32
|
+
/** Accessible label for the nav. Defaults to a translated built-in. */
|
|
33
|
+
ariaLabel?: string;
|
|
34
|
+
className?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const INDENT: Record<number, string> = {
|
|
38
|
+
2: "",
|
|
39
|
+
3: "pl-3",
|
|
40
|
+
4: "pl-6",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export function TableOfContents({
|
|
44
|
+
items,
|
|
45
|
+
targetRef,
|
|
46
|
+
offset = 0,
|
|
47
|
+
history = true,
|
|
48
|
+
ariaLabel,
|
|
49
|
+
className,
|
|
50
|
+
}: TableOfContentsProps): ReactElement {
|
|
51
|
+
const { t } = useTranslation();
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<nav
|
|
55
|
+
aria-label={ariaLabel ?? t("middag.ui.table_of_contents.label")}
|
|
56
|
+
className={cn("text-sm", className)}
|
|
57
|
+
>
|
|
58
|
+
<Scrollspy targetRef={targetRef} offset={offset} history={history}>
|
|
59
|
+
<ul className="flex flex-col gap-0.5">
|
|
60
|
+
{items.map((item) => (
|
|
61
|
+
<li key={item.id} className={INDENT[item.level ?? 2] ?? ""}>
|
|
62
|
+
<a
|
|
63
|
+
href={`#${item.id}`}
|
|
64
|
+
data-scrollspy-anchor={item.id}
|
|
65
|
+
className={cn(
|
|
66
|
+
"text-muted-foreground hover:text-foreground block border-l-2 border-transparent py-1 pl-3 transition-colors",
|
|
67
|
+
"data-[active=true]:border-primary data-[active=true]:text-foreground data-[active=true]:font-medium",
|
|
68
|
+
)}
|
|
69
|
+
>
|
|
70
|
+
{item.label}
|
|
71
|
+
</a>
|
|
72
|
+
</li>
|
|
73
|
+
))}
|
|
74
|
+
</ul>
|
|
75
|
+
</Scrollspy>
|
|
76
|
+
</nav>
|
|
77
|
+
);
|
|
78
|
+
}
|