@devxcrew/react-ui 0.0.0-stage → 0.1.7
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 +85 -2
- package/package.json +105 -4
- package/src/blocks/agent-chat-workspace/agent-chat-workspace.tsx +162 -0
- package/src/blocks/agent-chat-workspace/index.ts +2 -0
- package/src/blocks/agent-provider-settings/agent-provider-settings.tsx +183 -0
- package/src/blocks/agent-provider-settings/index.ts +2 -0
- package/src/blocks/agent-task-workspace/agent-task-workspace.tsx +48 -0
- package/src/blocks/agent-task-workspace/index.ts +2 -0
- package/src/blocks/analysis-context/analysis-context.tsx +6 -0
- package/src/blocks/analysis-context/index.ts +1 -0
- package/src/blocks/app-header/app-header.tsx +159 -0
- package/src/blocks/app-header/index.ts +2 -0
- package/src/blocks/archived-chat-workspace/archived-chat-workspace.tsx +29 -0
- package/src/blocks/archived-chat-workspace/index.ts +2 -0
- package/src/blocks/auth/README.md +32 -0
- package/src/blocks/auth/admin-login-page.tsx +15 -0
- package/src/blocks/auth/admin-password-forgot-page.tsx +5 -0
- package/src/blocks/auth/auth-page-layout.tsx +90 -0
- package/src/blocks/auth/client-login-page.tsx +20 -0
- package/src/blocks/auth/client-password-forgot-page.tsx +5 -0
- package/src/blocks/auth/identity-management-desk.tsx +530 -0
- package/src/blocks/auth/index.ts +12 -0
- package/src/blocks/auth/login-page.tsx +206 -0
- package/src/blocks/auth/password-forgot-page.tsx +60 -0
- package/src/blocks/auth/portal-pages.tsx +32 -0
- package/src/blocks/auth/privileged-desk.tsx +55 -0
- package/src/blocks/auth/register-page.tsx +117 -0
- package/src/blocks/auth/session-boundary.tsx +296 -0
- package/src/blocks/auth/super-admin-login-page.tsx +15 -0
- package/src/blocks/auth/super-admin-password-forgot-page.tsx +5 -0
- package/src/blocks/blog/blog-card.tsx +156 -0
- package/src/blocks/blog/blog-reader.tsx +175 -0
- package/src/blocks/blog/blog-types.ts +47 -0
- package/src/blocks/blog/index.ts +3 -0
- package/src/blocks/chat-composer/chat-composer.tsx +140 -0
- package/src/blocks/chat-composer/index.ts +1 -0
- package/src/blocks/chat-history/chat-history.tsx +59 -0
- package/src/blocks/chat-history/index.ts +1 -0
- package/src/blocks/chat-response-progress/chat-response-progress.tsx +34 -0
- package/src/blocks/chat-response-progress/index.ts +2 -0
- package/src/blocks/chat-runtime-controls/chat-runtime-controls.tsx +56 -0
- package/src/blocks/chat-runtime-controls/index.ts +2 -0
- package/src/blocks/chat-runtime-trace/chat-runtime-trace.tsx +71 -0
- package/src/blocks/chat-runtime-trace/index.ts +2 -0
- package/src/blocks/codex-connection-settings/codex-connection-settings.tsx +42 -0
- package/src/blocks/codex-connection-settings/index.ts +1 -0
- package/src/blocks/dropzone/dropzone-file-item.tsx +113 -0
- package/src/blocks/dropzone/dropzone-types.ts +32 -0
- package/src/blocks/dropzone/dropzone.tsx +216 -0
- package/src/blocks/dropzone/index.ts +3 -0
- package/src/blocks/ecommerce/cart/cart-drawer.tsx +228 -0
- package/src/blocks/ecommerce/cart/cart-types.ts +27 -0
- package/src/blocks/ecommerce/cart/index.ts +2 -0
- package/src/blocks/ecommerce/categories/categories-types.ts +23 -0
- package/src/blocks/ecommerce/categories/category-showcase.tsx +125 -0
- package/src/blocks/ecommerce/categories/index.ts +2 -0
- package/src/blocks/ecommerce/checkout/checkout-types.ts +48 -0
- package/src/blocks/ecommerce/checkout/checkout-wizard.tsx +468 -0
- package/src/blocks/ecommerce/checkout/index.ts +2 -0
- package/src/blocks/ecommerce/comparison/comparison-types.ts +28 -0
- package/src/blocks/ecommerce/comparison/index.ts +2 -0
- package/src/blocks/ecommerce/comparison/product-comparison.tsx +174 -0
- package/src/blocks/ecommerce/coupon-wallet/coupon-wallet-types.ts +21 -0
- package/src/blocks/ecommerce/coupon-wallet/coupon-wallet.tsx +154 -0
- package/src/blocks/ecommerce/coupon-wallet/index.ts +2 -0
- package/src/blocks/ecommerce/delivery-tracker/delivery-tracker-types.ts +20 -0
- package/src/blocks/ecommerce/delivery-tracker/delivery-tracker.tsx +169 -0
- package/src/blocks/ecommerce/delivery-tracker/index.ts +2 -0
- package/src/blocks/ecommerce/index.ts +12 -0
- package/src/blocks/ecommerce/payment-methods/index.ts +2 -0
- package/src/blocks/ecommerce/payment-methods/payment-method-selector.tsx +224 -0
- package/src/blocks/ecommerce/payment-methods/payment-methods-types.ts +21 -0
- package/src/blocks/ecommerce/price-history/index.ts +2 -0
- package/src/blocks/ecommerce/price-history/price-history-chart.tsx +217 -0
- package/src/blocks/ecommerce/price-history/price-history-types.ts +16 -0
- package/src/blocks/ecommerce/reviews/index.ts +2 -0
- package/src/blocks/ecommerce/reviews/reviews-section.tsx +309 -0
- package/src/blocks/ecommerce/reviews/reviews-types.ts +26 -0
- package/src/blocks/ecommerce/wishlist/index.ts +2 -0
- package/src/blocks/ecommerce/wishlist/wishlist-grid.tsx +149 -0
- package/src/blocks/ecommerce/wishlist/wishlist-types.ts +19 -0
- package/src/blocks/execution-status/README.md +25 -0
- package/src/blocks/execution-status/execution-status.tsx +135 -0
- package/src/blocks/execution-status/index.ts +2 -0
- package/src/blocks/file-tree/file-icons.tsx +84 -0
- package/src/blocks/file-tree/file-tree-node.tsx +158 -0
- package/src/blocks/file-tree/file-tree-types.ts +33 -0
- package/src/blocks/file-tree/file-tree.tsx +163 -0
- package/src/blocks/file-tree/index.ts +5 -0
- package/src/blocks/filter-builder/filter-builder.tsx +169 -0
- package/src/blocks/filter-builder/filter-row.tsx +164 -0
- package/src/blocks/filter-builder/filter-types.ts +61 -0
- package/src/blocks/filter-builder/index.ts +12 -0
- package/src/blocks/footer/footer-types.ts +35 -0
- package/src/blocks/footer/index.ts +2 -0
- package/src/blocks/footer/site-footer.tsx +212 -0
- package/src/blocks/form/form-block.tsx +113 -0
- package/src/blocks/form/form-lookup-field.tsx +60 -0
- package/src/blocks/form/index.ts +4 -0
- package/src/blocks/handover-stack/handover-stack.tsx +41 -0
- package/src/blocks/handover-stack/index.ts +1 -0
- package/src/blocks/idea-handover/idea-handover-readiness.ts +41 -0
- package/src/blocks/idea-handover/idea-handover-workspace.tsx +150 -0
- package/src/blocks/idea-handover/index.ts +4 -0
- package/src/blocks/kanban/index.ts +11 -0
- package/src/blocks/kanban/kanban-board.tsx +146 -0
- package/src/blocks/kanban/kanban-card.tsx +149 -0
- package/src/blocks/kanban/kanban-column.tsx +102 -0
- package/src/blocks/kanban/kanban-types.ts +38 -0
- package/src/blocks/loader/global-loader.tsx +90 -0
- package/src/blocks/loader/index.ts +1 -0
- package/src/blocks/mascot/README.md +21 -0
- package/src/blocks/mascot/index.ts +2 -0
- package/src/blocks/mascot/mascot.tsx +202 -0
- package/src/blocks/master-list/README.md +21 -0
- package/src/blocks/master-list/index.ts +12 -0
- package/src/blocks/master-list/master-form.tsx +157 -0
- package/src/blocks/master-list/master-list-desk.tsx +370 -0
- package/src/blocks/master-list/master-list.tsx +189 -0
- package/src/blocks/master-list/types.ts +18 -0
- package/src/blocks/mermaid-preview/index.ts +1 -0
- package/src/blocks/mermaid-preview/mermaid-preview.tsx +164 -0
- package/src/blocks/notifications/README.md +7 -0
- package/src/blocks/notifications/index.ts +1 -0
- package/src/blocks/notifications/notification-center-page.tsx +73 -0
- package/src/blocks/pricing/index.ts +7 -0
- package/src/blocks/pricing/pricing-table.tsx +173 -0
- package/src/blocks/pricing/pricing-types.ts +34 -0
- package/src/blocks/product-card/index.ts +2 -0
- package/src/blocks/product-card/product-card-types.ts +35 -0
- package/src/blocks/product-card/product-card.tsx +183 -0
- package/src/blocks/table/data-table-block.tsx +313 -0
- package/src/blocks/table/data-table-filter-menu.tsx +48 -0
- package/src/blocks/table/data-table-icon-menu-trigger.tsx +44 -0
- package/src/blocks/table/data-table-menu-content.tsx +32 -0
- package/src/blocks/table/data-table-pagination.tsx +149 -0
- package/src/blocks/table/data-table-row-actions.tsx +53 -0
- package/src/blocks/table/data-table-status.tsx +42 -0
- package/src/blocks/table/data-table-toolbar.tsx +124 -0
- package/src/blocks/table/data-table-totals.tsx +31 -0
- package/src/blocks/table/index.ts +13 -0
- package/src/blocks/workspace/index.ts +19 -0
- package/src/blocks/workspace/workspace-action-card.tsx +73 -0
- package/src/blocks/workspace/workspace-application-header.tsx +67 -0
- package/src/blocks/workspace/workspace-entity-card.tsx +48 -0
- package/src/blocks/workspace/workspace-health-summary.tsx +15 -0
- package/src/blocks/workspace/workspace-metric-card.tsx +97 -0
- package/src/blocks/workspace/workspace-page-header.tsx +43 -0
- package/src/blocks/workspace/workspace-publish-status.tsx +15 -0
- package/src/blocks/workspace/workspace-route-checklist.tsx +28 -0
- package/src/blocks/workspace/workspace-runtime-status.tsx +48 -0
- package/src/blocks/workspace/workspace-section-card.tsx +42 -0
- package/src/components/accordion.tsx +65 -0
- package/src/components/alert-dialog.tsx +160 -0
- package/src/components/alert.tsx +68 -0
- package/src/components/aspect-ratio.tsx +22 -0
- package/src/components/attachment.tsx +195 -0
- package/src/components/avatar.tsx +90 -0
- package/src/components/badge.tsx +55 -0
- package/src/components/breadcrumb.tsx +100 -0
- package/src/components/bubble.tsx +123 -0
- package/src/components/button-group.tsx +79 -0
- package/src/components/button.tsx +71 -0
- package/src/components/calendar.tsx +185 -0
- package/src/components/card.tsx +100 -0
- package/src/components/carousel.tsx +229 -0
- package/src/components/chart.tsx +338 -0
- package/src/components/checkbox.tsx +27 -0
- package/src/components/collapsible.tsx +15 -0
- package/src/components/combobox.tsx +269 -0
- package/src/components/command.tsx +181 -0
- package/src/components/compact-model-switcher.tsx +128 -0
- package/src/components/context-menu.tsx +244 -0
- package/src/components/dialog.tsx +138 -0
- package/src/components/direction.tsx +1 -0
- package/src/components/drawer.tsx +208 -0
- package/src/components/dropdown-menu.tsx +257 -0
- package/src/components/empty.tsx +93 -0
- package/src/components/field.tsx +232 -0
- package/src/components/hover-card.tsx +45 -0
- package/src/components/input-group.tsx +146 -0
- package/src/components/input-otp.tsx +83 -0
- package/src/components/input.tsx +19 -0
- package/src/components/item.tsx +188 -0
- package/src/components/kbd.tsx +26 -0
- package/src/components/label.tsx +17 -0
- package/src/components/markdown-content.tsx +113 -0
- package/src/components/marker.tsx +67 -0
- package/src/components/menubar.tsx +267 -0
- package/src/components/message-scroller.tsx +91 -0
- package/src/components/message.tsx +84 -0
- package/src/components/native-select.tsx +54 -0
- package/src/components/navigation-menu.tsx +160 -0
- package/src/components/pagination.tsx +118 -0
- package/src/components/popover.tsx +74 -0
- package/src/components/progress.tsx +82 -0
- package/src/components/questionnaire.tsx +150 -0
- package/src/components/radio-group.tsx +35 -0
- package/src/components/resizable.tsx +41 -0
- package/src/components/rich-text-editor.tsx +604 -0
- package/src/components/scroll-area.tsx +47 -0
- package/src/components/select.tsx +189 -0
- package/src/components/separator.tsx +18 -0
- package/src/components/sheet.tsx +125 -0
- package/src/components/sidebar.tsx +693 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/slider.tsx +51 -0
- package/src/components/sonner.tsx +45 -0
- package/src/components/sparkline.tsx +231 -0
- package/src/components/spinner.tsx +20 -0
- package/src/components/status-badge.tsx +114 -0
- package/src/components/switch.tsx +31 -0
- package/src/components/table.tsx +91 -0
- package/src/components/tabs.tsx +72 -0
- package/src/components/textarea.tsx +17 -0
- package/src/components/toast.tsx +222 -0
- package/src/components/toggle-group.tsx +85 -0
- package/src/components/toggle.tsx +42 -0
- package/src/components/tooltip.tsx +53 -0
- package/src/design-system/README.md +55 -0
- package/src/design-system/action-intents.ts +21 -0
- package/src/design-system/agent-manifest.ts +83 -0
- package/src/design-system/block-registry.ts +272 -0
- package/src/design-system/component-registry.ts +142 -0
- package/src/design-system/contracts.ts +69 -0
- package/src/design-system/defaults.ts +3 -0
- package/src/design-system/index.ts +29 -0
- package/src/design-system/mcp-server.ts +156 -0
- package/src/design-system/page-registry.ts +74 -0
- package/src/design-system/selection.ts +67 -0
- package/src/design-system/template-registry.ts +33 -0
- package/src/features/interface-topology/index.ts +14 -0
- package/src/features/interface-topology/interface-topology.types.ts +40 -0
- package/src/features/interface-topology/topology-control.tsx +18 -0
- package/src/features/interface-topology/topology-inspector.tsx +228 -0
- package/src/features/interface-topology/topology-marker.tsx +47 -0
- package/src/features/interface-topology/topology-region.tsx +44 -0
- package/src/features/interface-topology/use-interface-topology.ts +178 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-scroll-follow.ts +22 -0
- package/src/index.ts +11 -0
- package/src/layouts/README.md +65 -0
- package/src/layouts/agent-workspace/agent-activity-rail.tsx +101 -0
- package/src/layouts/agent-workspace/agent-workspace.tsx +27 -0
- package/src/layouts/agent-workspace/agent-workspace.types.ts +28 -0
- package/src/layouts/agent-workspace/index.ts +7 -0
- package/src/layouts/blog-header/blog-header-types.ts +25 -0
- package/src/layouts/blog-header/blog-header.tsx +172 -0
- package/src/layouts/blog-header/index.ts +2 -0
- package/src/layouts/documentation-workspace/README.md +8 -0
- package/src/layouts/documentation-workspace/documentation-workspace.tsx +34 -0
- package/src/layouts/documentation-workspace/index.ts +1 -0
- package/src/layouts/ecommerce-header/ecommerce-actions.tsx +89 -0
- package/src/layouts/ecommerce-header/ecommerce-announcement.tsx +43 -0
- package/src/layouts/ecommerce-header/ecommerce-drawer.tsx +97 -0
- package/src/layouts/ecommerce-header/ecommerce-header-types.ts +59 -0
- package/src/layouts/ecommerce-header/ecommerce-header.tsx +47 -0
- package/src/layouts/ecommerce-header/ecommerce-navigation.tsx +98 -0
- package/src/layouts/ecommerce-header/ecommerce-search.tsx +86 -0
- package/src/layouts/ecommerce-header/index.ts +2 -0
- package/src/layouts/main-workspace/index.ts +28 -0
- package/src/layouts/mdi/index.ts +1 -0
- package/src/layouts/mdi/mdi.tsx +20 -0
- package/src/layouts/mdi-main/index.ts +27 -0
- package/src/layouts/mdi-main/mdi-app-catalog.generated.ts +159 -0
- package/src/layouts/mdi-main/mdi-app-catalog.ts +76 -0
- package/src/layouts/mdi-main/mdi-app-switcher.tsx +107 -0
- package/src/layouts/mdi-main/mdi-feature-settings.tsx +135 -0
- package/src/layouts/mdi-main/mdi-global-search.tsx +192 -0
- package/src/layouts/mdi-main/mdi-main.tsx +241 -0
- package/src/layouts/mdi-main/mdi-notifications-menu.tsx +197 -0
- package/src/layouts/mdi-main/mdi-profile-menu.tsx +79 -0
- package/src/layouts/mdi-main/mdi-sidebar-navigation.tsx +226 -0
- package/src/layouts/mdi-main/mdi-sidebar.tsx +110 -0
- package/src/layouts/mdi-main/mdi-status-bar.tsx +26 -0
- package/src/layouts/mdi-main/mdi-top-menu-control.ts +4 -0
- package/src/layouts/mdi-main/mdi-top-menu.tsx +117 -0
- package/src/layouts/mdi-main/mdi-topology.tsx +297 -0
- package/src/layouts/mdi-main/mdi-tweak-panel.tsx +104 -0
- package/src/layouts/mdi-main/mdi-types.ts +131 -0
- package/src/layouts/mdi-main/use-mdi-features.ts +36 -0
- package/src/layouts/mdi-main/use-mdi-sidebar-state.ts +59 -0
- package/src/layouts/site-header/announcement-bar.tsx +55 -0
- package/src/layouts/site-header/category-strip.tsx +41 -0
- package/src/layouts/site-header/index.ts +16 -0
- package/src/layouts/site-header/main-navbar.tsx +179 -0
- package/src/layouts/site-header/mobile-drawer.tsx +140 -0
- package/src/layouts/site-header/site-header-types.ts +63 -0
- package/src/layouts/site-header/site-header.tsx +58 -0
- package/src/lib/random-id.ts +19 -0
- package/src/lib/utils.ts +6 -0
- package/src/providers/pdf-provider.ts +137 -0
- package/src/styles/globals.css +374 -0
- package/src/templates/README.md +12 -0
- package/src/templates/dashboard-01/components/app-sidebar.tsx +177 -0
- package/src/templates/dashboard-01/components/chart-area-interactive.tsx +276 -0
- package/src/templates/dashboard-01/components/data-table-cell-viewer.tsx +213 -0
- package/src/templates/dashboard-01/components/data-table.tsx +577 -0
- package/src/templates/dashboard-01/components/nav-documents.tsx +79 -0
- package/src/templates/dashboard-01/components/nav-main.tsx +55 -0
- package/src/templates/dashboard-01/components/nav-secondary.tsx +39 -0
- package/src/templates/dashboard-01/components/nav-user.tsx +97 -0
- package/src/templates/dashboard-01/components/section-cards.tsx +99 -0
- package/src/templates/dashboard-01/components/site-header.tsx +14 -0
- package/src/templates/dashboard-01/data.json +614 -0
- package/src/templates/dashboard-01/index.ts +7 -0
- package/src/templates/documentation-sidebar/app-sidebar.tsx +95 -0
- package/src/templates/documentation-sidebar/index.ts +2 -0
- package/src/templates/sidebar-07/components/app-sidebar.tsx +175 -0
- package/src/templates/sidebar-07/components/nav-main.tsx +64 -0
- package/src/templates/sidebar-07/components/nav-projects.tsx +79 -0
- package/src/templates/sidebar-07/components/nav-user.tsx +105 -0
- package/src/templates/sidebar-07/components/team-switcher.tsx +94 -0
- package/src/templates/sidebar-07/index.ts +1 -0
- package/src/templates/ui-page/index.ts +7 -0
- package/src/templates/ui-page/ui-browser-frame.tsx +27 -0
- package/src/templates/ui-page/ui-template-code.tsx +48 -0
- package/src/templates/ui-page/ui-template-header.tsx +87 -0
- package/src/templates/ui-page/ui-template-navigation.tsx +60 -0
- package/src/templates/ui-page/ui-template-page.tsx +97 -0
- package/src/theme/index.ts +12 -0
- package/src/theme/theme-config.ts +30 -0
- package/src/theme/theme-provider.tsx +142 -0
- package/src/theme/theme-selector.tsx +75 -0
- package/src/tokens/index.ts +15 -0
- package/src/vite-env.d.ts +3 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { useMemo, useState, type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ArrowDownWideNarrow,
|
|
4
|
+
ChevronDown,
|
|
5
|
+
Ellipsis,
|
|
6
|
+
List,
|
|
7
|
+
Monitor,
|
|
8
|
+
PauseCircle,
|
|
9
|
+
Pencil,
|
|
10
|
+
Plus,
|
|
11
|
+
RefreshCw,
|
|
12
|
+
SlidersHorizontal,
|
|
13
|
+
Trash2,
|
|
14
|
+
X,
|
|
15
|
+
} from "lucide-react";
|
|
16
|
+
import { Button } from "@devxcrew/react-ui/components/button";
|
|
17
|
+
import { Checkbox } from "@devxcrew/react-ui/components/checkbox";
|
|
18
|
+
import { Input } from "@devxcrew/react-ui/components/input";
|
|
19
|
+
import { DataTableRowActions } from "@devxcrew/react-ui/blocks/table";
|
|
20
|
+
import { TopologyRegion, type InterfaceTopologyController } from "@devxcrew/react-ui/features/interface-topology";
|
|
21
|
+
import { cn } from "@devxcrew/react-ui/lib/utils";
|
|
22
|
+
|
|
23
|
+
export type MasterListDeskFilter = {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
operator?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type MasterListDeskColumn<TRecord> = {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
render: (record: TRecord) => ReactNode;
|
|
33
|
+
width?: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type MasterListDeskRecord = {
|
|
37
|
+
age?: string;
|
|
38
|
+
commentCount?: number;
|
|
39
|
+
favorite?: boolean;
|
|
40
|
+
id: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type MasterListDeskProps<TRecord extends MasterListDeskRecord> = {
|
|
44
|
+
columns: readonly MasterListDeskColumn<TRecord>[];
|
|
45
|
+
filters: readonly MasterListDeskFilter[];
|
|
46
|
+
records: readonly TRecord[];
|
|
47
|
+
title: string;
|
|
48
|
+
primaryActionLabel: string;
|
|
49
|
+
getFilterValue: (record: TRecord, filterId: string) => string;
|
|
50
|
+
filterPlacement?: "top" | "columns";
|
|
51
|
+
onPrimaryAction?: () => void;
|
|
52
|
+
onEdit?: (record: TRecord) => void;
|
|
53
|
+
onDelete?: (record: TRecord) => void;
|
|
54
|
+
onSuspend?: (record: TRecord) => void;
|
|
55
|
+
onRefresh?: () => void;
|
|
56
|
+
sortLabel?: string;
|
|
57
|
+
totalLabel?: string;
|
|
58
|
+
topology?: InterfaceTopologyController;
|
|
59
|
+
topologyIds?: {
|
|
60
|
+
content?: string;
|
|
61
|
+
deskFilters?: string;
|
|
62
|
+
filterActions?: string;
|
|
63
|
+
filterRow?: string;
|
|
64
|
+
header?: string;
|
|
65
|
+
loadMore?: string;
|
|
66
|
+
newButton?: string;
|
|
67
|
+
pagination?: string;
|
|
68
|
+
rowHeader?: string;
|
|
69
|
+
rows?: string;
|
|
70
|
+
title?: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
function DeskRegion({
|
|
75
|
+
as = "div",
|
|
76
|
+
children,
|
|
77
|
+
className,
|
|
78
|
+
id,
|
|
79
|
+
topology,
|
|
80
|
+
...props
|
|
81
|
+
}: {
|
|
82
|
+
as?: "div" | "header" | "footer" | "h2";
|
|
83
|
+
children: ReactNode;
|
|
84
|
+
className?: string;
|
|
85
|
+
id?: string;
|
|
86
|
+
topology?: InterfaceTopologyController;
|
|
87
|
+
} & Omit<HTMLAttributes<HTMLElement>, "id">) {
|
|
88
|
+
if (topology && id) {
|
|
89
|
+
return (
|
|
90
|
+
<TopologyRegion as={as} className={className} id={id} topology={topology} {...props}>
|
|
91
|
+
{children}
|
|
92
|
+
</TopologyRegion>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
const Component = as;
|
|
96
|
+
return (
|
|
97
|
+
<Component className={className} {...props}>
|
|
98
|
+
{children}
|
|
99
|
+
</Component>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function MasterListDesk<TRecord extends MasterListDeskRecord>({
|
|
104
|
+
columns,
|
|
105
|
+
filters,
|
|
106
|
+
records,
|
|
107
|
+
title,
|
|
108
|
+
primaryActionLabel,
|
|
109
|
+
getFilterValue,
|
|
110
|
+
filterPlacement = "top",
|
|
111
|
+
onPrimaryAction,
|
|
112
|
+
onEdit,
|
|
113
|
+
onDelete,
|
|
114
|
+
onSuspend,
|
|
115
|
+
onRefresh,
|
|
116
|
+
sortLabel = "Last Updated",
|
|
117
|
+
totalLabel,
|
|
118
|
+
topology,
|
|
119
|
+
topologyIds,
|
|
120
|
+
}: MasterListDeskProps<TRecord>) {
|
|
121
|
+
const [filterValues, setFilterValues] = useState<Record<string, string>>({});
|
|
122
|
+
const [selectedIds, setSelectedIds] = useState<Set<string>>(() => new Set());
|
|
123
|
+
const [pageSize, setPageSize] = useState(20);
|
|
124
|
+
const visibleRecords = useMemo(
|
|
125
|
+
() =>
|
|
126
|
+
records.filter((record) =>
|
|
127
|
+
filters.every((filter) => {
|
|
128
|
+
const query = filterValues[filter.id]?.trim().toLowerCase();
|
|
129
|
+
return !query || getFilterValue(record, filter.id).toLowerCase().includes(query);
|
|
130
|
+
}),
|
|
131
|
+
),
|
|
132
|
+
[filterValues, filters, getFilterValue, records],
|
|
133
|
+
);
|
|
134
|
+
const gridTemplateColumns = `32px ${columns.map((column) => column.width ?? "minmax(140px, 1fr)").join(" ")} 52px`;
|
|
135
|
+
const allSelected = visibleRecords.length > 0 && visibleRecords.every(({ id }) => selectedIds.has(id));
|
|
136
|
+
const activeFilterCount = Object.values(filterValues).filter((value) => value.trim()).length;
|
|
137
|
+
|
|
138
|
+
function toggleAll(checked: boolean) {
|
|
139
|
+
setSelectedIds(checked ? new Set(visibleRecords.map(({ id }) => id)) : new Set());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function toggleRecord(recordId: string, checked: boolean) {
|
|
143
|
+
setSelectedIds((current) => {
|
|
144
|
+
const next = new Set(current);
|
|
145
|
+
if (checked) next.add(recordId);
|
|
146
|
+
else next.delete(recordId);
|
|
147
|
+
return next;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<section className="w-full bg-background text-sm">
|
|
153
|
+
<DeskRegion
|
|
154
|
+
as="header"
|
|
155
|
+
className="flex min-h-12 flex-wrap items-center justify-between gap-3 border-b px-3 py-2"
|
|
156
|
+
id={topologyIds?.header}
|
|
157
|
+
topology={topology}
|
|
158
|
+
>
|
|
159
|
+
<DeskRegion
|
|
160
|
+
as="h2"
|
|
161
|
+
className="flex items-center gap-2 font-semibold"
|
|
162
|
+
id={topologyIds?.title}
|
|
163
|
+
topology={topology}
|
|
164
|
+
>
|
|
165
|
+
<Monitor className="size-4 text-muted-foreground" />
|
|
166
|
+
<span aria-hidden="true">/</span>
|
|
167
|
+
{title}
|
|
168
|
+
</DeskRegion>
|
|
169
|
+
<DeskRegion className="flex flex-wrap items-center gap-2" id={topologyIds?.newButton} topology={topology}>
|
|
170
|
+
<Button size="sm" variant="secondary">
|
|
171
|
+
<List />
|
|
172
|
+
List View
|
|
173
|
+
<ChevronDown />
|
|
174
|
+
</Button>
|
|
175
|
+
<Button size="sm" variant="secondary">
|
|
176
|
+
Saved Filters
|
|
177
|
+
<ChevronDown />
|
|
178
|
+
</Button>
|
|
179
|
+
<Button aria-label="Refresh list" onClick={onRefresh} size="icon-sm" variant="secondary">
|
|
180
|
+
<RefreshCw />
|
|
181
|
+
</Button>
|
|
182
|
+
<Button aria-label="More list actions" size="icon-sm" variant="secondary">
|
|
183
|
+
<Ellipsis />
|
|
184
|
+
</Button>
|
|
185
|
+
<Button onClick={onPrimaryAction} size="sm">
|
|
186
|
+
<Plus />
|
|
187
|
+
{primaryActionLabel}
|
|
188
|
+
</Button>
|
|
189
|
+
</DeskRegion>
|
|
190
|
+
</DeskRegion>
|
|
191
|
+
|
|
192
|
+
<div className="flex flex-col gap-3 p-3">
|
|
193
|
+
{filterPlacement === "top" ? (
|
|
194
|
+
<DeskRegion
|
|
195
|
+
className="flex flex-wrap items-start justify-between gap-3"
|
|
196
|
+
id={topologyIds?.deskFilters}
|
|
197
|
+
topology={topology}
|
|
198
|
+
>
|
|
199
|
+
<div className="grid min-w-0 flex-1 grid-cols-2 gap-2 md:grid-cols-3 xl:grid-cols-6">
|
|
200
|
+
{filters.map((filter) => (
|
|
201
|
+
<div className="relative" key={filter.id}>
|
|
202
|
+
<Input
|
|
203
|
+
aria-label={filter.label}
|
|
204
|
+
className="h-8 rounded-sm border-transparent bg-muted pr-8 shadow-none focus-visible:bg-background"
|
|
205
|
+
onChange={(event) =>
|
|
206
|
+
setFilterValues((current) => ({ ...current, [filter.id]: event.target.value }))
|
|
207
|
+
}
|
|
208
|
+
value={filterValues[filter.id] ?? ""}
|
|
209
|
+
/>
|
|
210
|
+
{filter.operator ? (
|
|
211
|
+
<SlidersHorizontal className="pointer-events-none absolute right-2 top-2 size-4 text-muted-foreground" />
|
|
212
|
+
) : null}
|
|
213
|
+
</div>
|
|
214
|
+
))}
|
|
215
|
+
</div>
|
|
216
|
+
<DeskRegion className="flex shrink-0 gap-2" id={topologyIds?.filterActions} topology={topology}>
|
|
217
|
+
<Button size="sm" variant="secondary">
|
|
218
|
+
<SlidersHorizontal />
|
|
219
|
+
Filter{activeFilterCount ? ` ${activeFilterCount}` : ""}
|
|
220
|
+
</Button>
|
|
221
|
+
{activeFilterCount ? (
|
|
222
|
+
<Button
|
|
223
|
+
aria-label="Clear all filters"
|
|
224
|
+
onClick={() => setFilterValues({})}
|
|
225
|
+
size="icon-sm"
|
|
226
|
+
variant="secondary"
|
|
227
|
+
>
|
|
228
|
+
<X />
|
|
229
|
+
</Button>
|
|
230
|
+
) : null}
|
|
231
|
+
<Button size="sm" variant="secondary">
|
|
232
|
+
<ArrowDownWideNarrow />
|
|
233
|
+
{sortLabel}
|
|
234
|
+
<ChevronDown />
|
|
235
|
+
</Button>
|
|
236
|
+
</DeskRegion>
|
|
237
|
+
</DeskRegion>
|
|
238
|
+
) : null}
|
|
239
|
+
|
|
240
|
+
<DeskRegion className="overflow-x-auto border-y border-border/70" id={topologyIds?.content} topology={topology}>
|
|
241
|
+
<div className="min-w-[1180px]">
|
|
242
|
+
<DeskRegion
|
|
243
|
+
className="grid min-h-8 items-center border-b border-border bg-muted px-2 text-sm text-muted-foreground"
|
|
244
|
+
aria-label="Table header"
|
|
245
|
+
id={topologyIds?.rowHeader}
|
|
246
|
+
topology={topology}
|
|
247
|
+
role="row"
|
|
248
|
+
style={{ gridTemplateColumns }}
|
|
249
|
+
>
|
|
250
|
+
<Checkbox aria-label="Select all" checked={allSelected} onCheckedChange={toggleAll} />
|
|
251
|
+
{columns.map((column) => (
|
|
252
|
+
<span className="truncate px-2" key={column.id}>
|
|
253
|
+
{column.label}
|
|
254
|
+
</span>
|
|
255
|
+
))}
|
|
256
|
+
<span aria-label={`${visibleRecords.length} of ${totalLabel ?? records.length}`} />
|
|
257
|
+
</DeskRegion>
|
|
258
|
+
{filterPlacement === "columns" ? (
|
|
259
|
+
<DeskRegion
|
|
260
|
+
aria-label="Column filters"
|
|
261
|
+
className="grid min-h-10 items-center border-t border-border/60 bg-background px-2"
|
|
262
|
+
data-row="filters"
|
|
263
|
+
id={topologyIds?.filterRow}
|
|
264
|
+
topology={topology}
|
|
265
|
+
role="row"
|
|
266
|
+
style={{ gridTemplateColumns }}
|
|
267
|
+
>
|
|
268
|
+
<span aria-hidden="true" />
|
|
269
|
+
{columns.map((column) => {
|
|
270
|
+
const filter = filters.find((candidate) => candidate.id === column.id);
|
|
271
|
+
return (
|
|
272
|
+
<div className="min-w-0 px-2" key={column.id}>
|
|
273
|
+
{filter ? (
|
|
274
|
+
<Input
|
|
275
|
+
aria-label={filter.label}
|
|
276
|
+
className="h-7 rounded-sm border-transparent bg-muted px-2 text-xs shadow-none focus-visible:bg-background"
|
|
277
|
+
onChange={(event) =>
|
|
278
|
+
setFilterValues((current) => ({ ...current, [filter.id]: event.target.value }))
|
|
279
|
+
}
|
|
280
|
+
value={filterValues[filter.id] ?? ""}
|
|
281
|
+
/>
|
|
282
|
+
) : null}
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
})}
|
|
286
|
+
<span aria-hidden="true" />
|
|
287
|
+
</DeskRegion>
|
|
288
|
+
) : null}
|
|
289
|
+
<DeskRegion id={topologyIds?.rows} topology={topology}>
|
|
290
|
+
{visibleRecords.map((record) => (
|
|
291
|
+
<div
|
|
292
|
+
className="grid min-h-10 items-center border-t border-border/60 px-2 hover:bg-muted/70"
|
|
293
|
+
key={record.id}
|
|
294
|
+
role="row"
|
|
295
|
+
style={{ gridTemplateColumns }}
|
|
296
|
+
>
|
|
297
|
+
<Checkbox
|
|
298
|
+
aria-label={`Select ${record.id}`}
|
|
299
|
+
checked={selectedIds.has(record.id)}
|
|
300
|
+
onCheckedChange={(checked) => toggleRecord(record.id, checked)}
|
|
301
|
+
/>
|
|
302
|
+
{columns.map((column, index) => (
|
|
303
|
+
<div
|
|
304
|
+
className={cn(
|
|
305
|
+
"truncate px-2 text-muted-foreground",
|
|
306
|
+
index === 0 && "font-medium text-foreground",
|
|
307
|
+
)}
|
|
308
|
+
key={column.id}
|
|
309
|
+
>
|
|
310
|
+
{column.render(record)}
|
|
311
|
+
</div>
|
|
312
|
+
))}
|
|
313
|
+
<DataTableRowActions
|
|
314
|
+
actions={[
|
|
315
|
+
{ id: "edit", label: "Edit", icon: <Pencil />, onSelect: () => onEdit?.(record) },
|
|
316
|
+
{
|
|
317
|
+
id: "suspend",
|
|
318
|
+
label: "Suspend",
|
|
319
|
+
icon: <PauseCircle />,
|
|
320
|
+
onSelect: () => onSuspend?.(record),
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: "delete",
|
|
324
|
+
label: "Delete",
|
|
325
|
+
icon: <Trash2 />,
|
|
326
|
+
onSelect: () => onDelete?.(record),
|
|
327
|
+
separatorBefore: true,
|
|
328
|
+
tone: "destructive",
|
|
329
|
+
},
|
|
330
|
+
]}
|
|
331
|
+
label={`Actions for ${record.id}`}
|
|
332
|
+
/>
|
|
333
|
+
</div>
|
|
334
|
+
))}
|
|
335
|
+
</DeskRegion>
|
|
336
|
+
{!visibleRecords.length ? (
|
|
337
|
+
<p className="p-8 text-center text-muted-foreground">No records match these filters.</p>
|
|
338
|
+
) : null}
|
|
339
|
+
</div>
|
|
340
|
+
</DeskRegion>
|
|
341
|
+
|
|
342
|
+
<DeskRegion
|
|
343
|
+
as="footer"
|
|
344
|
+
className="flex items-center justify-between gap-3"
|
|
345
|
+
id={topologyIds?.pagination}
|
|
346
|
+
topology={topology}
|
|
347
|
+
>
|
|
348
|
+
<div className="flex items-center gap-1" aria-label="Rows per page">
|
|
349
|
+
{[20, 100, 500, 2500].map((size) => (
|
|
350
|
+
<Button
|
|
351
|
+
aria-pressed={pageSize === size}
|
|
352
|
+
key={size}
|
|
353
|
+
onClick={() => setPageSize(size)}
|
|
354
|
+
size="xs"
|
|
355
|
+
variant={pageSize === size ? "secondary" : "ghost"}
|
|
356
|
+
>
|
|
357
|
+
{size}
|
|
358
|
+
</Button>
|
|
359
|
+
))}
|
|
360
|
+
</div>
|
|
361
|
+
<DeskRegion id={topologyIds?.loadMore} topology={topology}>
|
|
362
|
+
<Button size="sm" variant="secondary">
|
|
363
|
+
Load More
|
|
364
|
+
</Button>
|
|
365
|
+
</DeskRegion>
|
|
366
|
+
</DeskRegion>
|
|
367
|
+
</div>
|
|
368
|
+
</section>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { useMemo, useState } from "react";
|
|
2
|
+
import { MoreHorizontal, Plus } from "lucide-react";
|
|
3
|
+
import { Button } from "@devxcrew/react-ui/components/button";
|
|
4
|
+
import { Input } from "@devxcrew/react-ui/components/input";
|
|
5
|
+
import {
|
|
6
|
+
createDataTableColumnHelper,
|
|
7
|
+
DataTableBlock,
|
|
8
|
+
DataTableRowActions,
|
|
9
|
+
type DataTableColumn,
|
|
10
|
+
} from "@devxcrew/react-ui/blocks/table";
|
|
11
|
+
import type { InterfaceTopologyController } from "@devxcrew/react-ui/features/interface-topology";
|
|
12
|
+
import type { MasterField, MasterRecord, MasterValue } from "./types";
|
|
13
|
+
|
|
14
|
+
export type MasterListProps = {
|
|
15
|
+
fields: readonly MasterField[];
|
|
16
|
+
records: readonly MasterRecord[];
|
|
17
|
+
title: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
emptyMessage?: string;
|
|
20
|
+
createLabel?: string;
|
|
21
|
+
variant?: "table" | "cards";
|
|
22
|
+
showHeader?: boolean;
|
|
23
|
+
showHeaderDivider?: boolean;
|
|
24
|
+
searchTopSpacing?: boolean;
|
|
25
|
+
topology?: InterfaceTopologyController;
|
|
26
|
+
topologyIds?: {
|
|
27
|
+
header: string;
|
|
28
|
+
search: string;
|
|
29
|
+
content: string;
|
|
30
|
+
pagination: string;
|
|
31
|
+
searchBar?: string;
|
|
32
|
+
columnFilter?: string;
|
|
33
|
+
rowHeader?: string;
|
|
34
|
+
rows?: string;
|
|
35
|
+
pageSize?: string;
|
|
36
|
+
pageNavigation?: string;
|
|
37
|
+
};
|
|
38
|
+
onCreate?: () => void;
|
|
39
|
+
onView?: (record: MasterRecord) => void;
|
|
40
|
+
onEdit?: (record: MasterRecord) => void;
|
|
41
|
+
onDelete?: (record: MasterRecord) => void;
|
|
42
|
+
onSuspend?: (record: MasterRecord) => void;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const columnHelper = createDataTableColumnHelper<MasterRecord>();
|
|
46
|
+
|
|
47
|
+
function displayValue(field: MasterField, record: MasterRecord) {
|
|
48
|
+
const value: MasterValue = record[field.id];
|
|
49
|
+
if (field.format) return field.format(value, record);
|
|
50
|
+
if (typeof value === "boolean") return value ? "Yes" : "No";
|
|
51
|
+
return value ?? "—";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function recordActions(record: MasterRecord, props: MasterListProps) {
|
|
55
|
+
return [
|
|
56
|
+
...(props.onView ? [{ id: "view", label: "View", onSelect: () => props.onView?.(record) }] : []),
|
|
57
|
+
...(props.onEdit ? [{ id: "edit", label: "Edit", onSelect: () => props.onEdit?.(record) }] : []),
|
|
58
|
+
...(props.onSuspend ? [{ id: "suspend", label: "Suspend", onSelect: () => props.onSuspend?.(record) }] : []),
|
|
59
|
+
...(props.onDelete
|
|
60
|
+
? [
|
|
61
|
+
{
|
|
62
|
+
id: "delete",
|
|
63
|
+
label: "Delete",
|
|
64
|
+
tone: "destructive" as const,
|
|
65
|
+
separatorBefore: true,
|
|
66
|
+
onSelect: () => props.onDelete?.(record),
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
: []),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function MasterCards(props: MasterListProps & { visibleFields: readonly MasterField[] }) {
|
|
74
|
+
const [search, setSearch] = useState("");
|
|
75
|
+
const headingField = props.visibleFields.find((field) => field.id === "name") ?? props.visibleFields[0];
|
|
76
|
+
const filtered = props.records.filter((record) =>
|
|
77
|
+
props.visibleFields.some((field) =>
|
|
78
|
+
String(record[field.id] ?? "")
|
|
79
|
+
.toLowerCase()
|
|
80
|
+
.includes(search.trim().toLowerCase()),
|
|
81
|
+
),
|
|
82
|
+
);
|
|
83
|
+
return (
|
|
84
|
+
<section className="w-full space-y-4">
|
|
85
|
+
{props.showHeader !== false ? (
|
|
86
|
+
<header className="flex flex-wrap items-start justify-between gap-4 border-b pb-4">
|
|
87
|
+
<div>
|
|
88
|
+
<h2 className="text-2xl font-semibold tracking-tight">{props.title}</h2>
|
|
89
|
+
{props.description ? <p className="mt-1 text-sm text-muted-foreground">{props.description}</p> : null}
|
|
90
|
+
</div>
|
|
91
|
+
{props.onCreate ? (
|
|
92
|
+
<Button onClick={props.onCreate}>
|
|
93
|
+
<Plus />
|
|
94
|
+
{props.createLabel ?? "Add record"}
|
|
95
|
+
</Button>
|
|
96
|
+
) : null}
|
|
97
|
+
</header>
|
|
98
|
+
) : null}
|
|
99
|
+
<Input
|
|
100
|
+
aria-label={`Search ${props.title}`}
|
|
101
|
+
className="max-w-sm"
|
|
102
|
+
onChange={(event) => setSearch(event.target.value)}
|
|
103
|
+
placeholder="Search records"
|
|
104
|
+
value={search}
|
|
105
|
+
/>
|
|
106
|
+
{filtered.length ? (
|
|
107
|
+
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
|
108
|
+
{filtered.map((record) => (
|
|
109
|
+
<article className="min-w-0 rounded-lg border bg-card p-4 shadow-sm" key={record.id}>
|
|
110
|
+
<div className="flex items-start justify-between gap-2">
|
|
111
|
+
<h3 className="truncate font-semibold">{String(record[headingField?.id] ?? record.id)}</h3>
|
|
112
|
+
<DataTableRowActions actions={recordActions(record, props)} label={`Actions for ${record.id}`} />
|
|
113
|
+
</div>
|
|
114
|
+
<dl className="mt-4 grid gap-3 text-sm">
|
|
115
|
+
{props.visibleFields
|
|
116
|
+
.filter((field) => field.id !== headingField?.id)
|
|
117
|
+
.map((field) => (
|
|
118
|
+
<div className="flex justify-between gap-3" key={field.id}>
|
|
119
|
+
<dt className="text-muted-foreground">{field.label}</dt>
|
|
120
|
+
<dd className="min-w-0 truncate text-right">{displayValue(field, record)}</dd>
|
|
121
|
+
</div>
|
|
122
|
+
))}
|
|
123
|
+
</dl>
|
|
124
|
+
</article>
|
|
125
|
+
))}
|
|
126
|
+
</div>
|
|
127
|
+
) : (
|
|
128
|
+
<p className="rounded-lg border p-8 text-center text-sm text-muted-foreground">
|
|
129
|
+
{props.emptyMessage ?? "No records found."}
|
|
130
|
+
</p>
|
|
131
|
+
)}
|
|
132
|
+
</section>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function MasterList(props: MasterListProps) {
|
|
137
|
+
const visibleFields = useMemo(() => props.fields.filter((field) => field.showInList !== false), [props.fields]);
|
|
138
|
+
const statusField = visibleFields.find((field) => field.id === "status");
|
|
139
|
+
const columns = useMemo(() => {
|
|
140
|
+
const result: DataTableColumn<MasterRecord>[] = visibleFields.map((field) =>
|
|
141
|
+
columnHelper.display({ id: field.id, header: field.label, cell: ({ row }) => displayValue(field, row.original) }),
|
|
142
|
+
);
|
|
143
|
+
if (props.onView || props.onEdit || props.onSuspend || props.onDelete) {
|
|
144
|
+
result.push(
|
|
145
|
+
columnHelper.display({
|
|
146
|
+
id: "actions",
|
|
147
|
+
header: () => <MoreHorizontal aria-label="Actions" size={16} />,
|
|
148
|
+
enableHiding: false,
|
|
149
|
+
cell: ({ row }) => (
|
|
150
|
+
<DataTableRowActions
|
|
151
|
+
actions={recordActions(row.original, props)}
|
|
152
|
+
label={`Actions for ${row.original.id}`}
|
|
153
|
+
/>
|
|
154
|
+
),
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}, [visibleFields, props.onView, props.onEdit, props.onSuspend, props.onDelete]);
|
|
160
|
+
|
|
161
|
+
if (props.variant === "cards") return <MasterCards {...props} visibleFields={visibleFields} />;
|
|
162
|
+
return (
|
|
163
|
+
<DataTableBlock
|
|
164
|
+
columns={columns}
|
|
165
|
+
data={[...props.records]}
|
|
166
|
+
description={props.showHeader === false ? undefined : props.description}
|
|
167
|
+
emptyMessage={props.emptyMessage ?? "No records found."}
|
|
168
|
+
getRowId={(row) => row.id}
|
|
169
|
+
getSearchText={(row) => visibleFields.map((field) => String(row[field.id] ?? "")).join(" ")}
|
|
170
|
+
filterOptions={statusField?.options}
|
|
171
|
+
getFilterValue={(row) => String(row.status ?? "")}
|
|
172
|
+
itemLabel="records"
|
|
173
|
+
pageWidth="full"
|
|
174
|
+
showHeaderDivider={props.showHeaderDivider}
|
|
175
|
+
searchTopSpacing={props.searchTopSpacing}
|
|
176
|
+
primaryAction={
|
|
177
|
+
props.showHeader === false ? undefined : props.onCreate ? (
|
|
178
|
+
<Button onClick={props.onCreate}>
|
|
179
|
+
<Plus />
|
|
180
|
+
{props.createLabel ?? "Add record"}
|
|
181
|
+
</Button>
|
|
182
|
+
) : undefined
|
|
183
|
+
}
|
|
184
|
+
title={props.showHeader === false ? undefined : props.title}
|
|
185
|
+
topology={props.topology}
|
|
186
|
+
topologyIds={props.topologyIds}
|
|
187
|
+
/>
|
|
188
|
+
);
|
|
189
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type MasterValue = string | number | boolean | null | undefined;
|
|
4
|
+
|
|
5
|
+
export type MasterRecord = { id: string } & Record<string, MasterValue>;
|
|
6
|
+
|
|
7
|
+
export type MasterField = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
type?: 'text' | 'email' | 'number' | 'textarea' | 'select';
|
|
11
|
+
options?: readonly { label: string; value: string }[];
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
showInList?: boolean;
|
|
15
|
+
format?: (value: MasterValue, record: MasterRecord) => ReactNode;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type MasterFormValues = Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MermaidPreview } from './mermaid-preview'
|