@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,313 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
columnVisibilityFeature,
|
|
4
|
+
createColumnHelper,
|
|
5
|
+
createPaginatedRowModel,
|
|
6
|
+
createSortedRowModel,
|
|
7
|
+
FlexRender,
|
|
8
|
+
rowPaginationFeature,
|
|
9
|
+
rowSortingFeature,
|
|
10
|
+
tableFeatures,
|
|
11
|
+
useTable,
|
|
12
|
+
type ColumnDef,
|
|
13
|
+
type ColumnVisibilityState,
|
|
14
|
+
type PaginationState,
|
|
15
|
+
type RowData,
|
|
16
|
+
} from "@tanstack/react-table";
|
|
17
|
+
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@devxcrew/react-ui/components/table";
|
|
18
|
+
import { cn } from "@devxcrew/react-ui/lib/utils";
|
|
19
|
+
import { TopologyRegion, type InterfaceTopologyController } from "@devxcrew/react-ui/features/interface-topology";
|
|
20
|
+
import { DataTablePagination } from "./data-table-pagination";
|
|
21
|
+
import { DataTableToolbar } from "./data-table-toolbar";
|
|
22
|
+
|
|
23
|
+
export const dataTableFeatures = tableFeatures({
|
|
24
|
+
columnVisibilityFeature,
|
|
25
|
+
rowPaginationFeature,
|
|
26
|
+
rowSortingFeature,
|
|
27
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
28
|
+
sortedRowModel: createSortedRowModel(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export type DataTableColumn<TData extends RowData> = ColumnDef<typeof dataTableFeatures, TData, unknown>;
|
|
32
|
+
|
|
33
|
+
export function createDataTableColumnHelper<TData extends RowData>() {
|
|
34
|
+
return createColumnHelper<typeof dataTableFeatures, TData>();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type DataTableBlockProps<TData extends RowData> = {
|
|
38
|
+
columns: DataTableColumn<TData>[];
|
|
39
|
+
data: TData[];
|
|
40
|
+
description?: string;
|
|
41
|
+
emptyMessage: string;
|
|
42
|
+
getRowId: (row: TData) => string;
|
|
43
|
+
getSearchText: (row: TData) => string;
|
|
44
|
+
filterOptions?: readonly { label: string; value: string }[];
|
|
45
|
+
getFilterValue?: (row: TData) => string;
|
|
46
|
+
layout?: "page" | "section";
|
|
47
|
+
primaryAction?: React.ReactNode;
|
|
48
|
+
pageWidth?: "full" | "wide";
|
|
49
|
+
defaultPageSize?: number;
|
|
50
|
+
itemLabel?: string;
|
|
51
|
+
pageSizeOptions?: readonly number[];
|
|
52
|
+
searchPlaceholder?: string;
|
|
53
|
+
showSerialNumber?: boolean;
|
|
54
|
+
showHeaderDivider?: boolean;
|
|
55
|
+
searchTopSpacing?: boolean;
|
|
56
|
+
summary?: React.ReactNode;
|
|
57
|
+
tableFooter?: React.ReactNode;
|
|
58
|
+
title?: string;
|
|
59
|
+
toolbarFilters?: React.ReactNode;
|
|
60
|
+
withPagination?: boolean;
|
|
61
|
+
withToolbar?: boolean;
|
|
62
|
+
topology?: InterfaceTopologyController;
|
|
63
|
+
topologyIds?: {
|
|
64
|
+
header: string;
|
|
65
|
+
search: string;
|
|
66
|
+
content: string;
|
|
67
|
+
pagination: string;
|
|
68
|
+
searchBar?: string;
|
|
69
|
+
columnFilter?: string;
|
|
70
|
+
rowHeader?: string;
|
|
71
|
+
rows?: string;
|
|
72
|
+
pageSize?: string;
|
|
73
|
+
pageNavigation?: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export function DataTableBlock<TData extends RowData>({
|
|
78
|
+
columns,
|
|
79
|
+
data,
|
|
80
|
+
description,
|
|
81
|
+
emptyMessage,
|
|
82
|
+
getRowId,
|
|
83
|
+
getSearchText,
|
|
84
|
+
filterOptions,
|
|
85
|
+
getFilterValue,
|
|
86
|
+
primaryAction,
|
|
87
|
+
pageWidth = "wide",
|
|
88
|
+
defaultPageSize = 10,
|
|
89
|
+
itemLabel = "records",
|
|
90
|
+
layout = "page",
|
|
91
|
+
pageSizeOptions = [10, 25, 50, 100],
|
|
92
|
+
searchPlaceholder = "Search",
|
|
93
|
+
showSerialNumber = true,
|
|
94
|
+
showHeaderDivider = true,
|
|
95
|
+
searchTopSpacing = false,
|
|
96
|
+
summary,
|
|
97
|
+
tableFooter,
|
|
98
|
+
title,
|
|
99
|
+
toolbarFilters,
|
|
100
|
+
withPagination = true,
|
|
101
|
+
withToolbar = true,
|
|
102
|
+
topology,
|
|
103
|
+
topologyIds,
|
|
104
|
+
}: DataTableBlockProps<TData>) {
|
|
105
|
+
const [search, setSearch] = React.useState("");
|
|
106
|
+
const [filterValue, setFilterValue] = React.useState("");
|
|
107
|
+
const [columnVisibility, setColumnVisibility] = React.useState<ColumnVisibilityState>({});
|
|
108
|
+
const [pagination, setPagination] = React.useState<PaginationState>({
|
|
109
|
+
pageIndex: 0,
|
|
110
|
+
pageSize: defaultPageSize,
|
|
111
|
+
});
|
|
112
|
+
const visibleData = React.useMemo(() => {
|
|
113
|
+
const normalized = search.trim().toLocaleLowerCase();
|
|
114
|
+
return data.filter((row) => {
|
|
115
|
+
const matchesSearch = !normalized || getSearchText(row).toLocaleLowerCase().includes(normalized);
|
|
116
|
+
const matchesFilter = !filterValue || !getFilterValue || getFilterValue(row) === filterValue;
|
|
117
|
+
return matchesSearch && matchesFilter;
|
|
118
|
+
});
|
|
119
|
+
}, [data, filterValue, getFilterValue, getSearchText, search]);
|
|
120
|
+
const table = useTable({
|
|
121
|
+
columns,
|
|
122
|
+
data: visibleData,
|
|
123
|
+
getRowId,
|
|
124
|
+
state: { columnVisibility, pagination },
|
|
125
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
126
|
+
onPaginationChange: setPagination,
|
|
127
|
+
features: dataTableFeatures,
|
|
128
|
+
});
|
|
129
|
+
const pageCount = Math.max(table.getPageCount(), 1);
|
|
130
|
+
const firstRow = visibleData.length ? pagination.pageIndex * pagination.pageSize + 1 : 0;
|
|
131
|
+
const lastRow = Math.min((pagination.pageIndex + 1) * pagination.pageSize, visibleData.length);
|
|
132
|
+
|
|
133
|
+
function updateSearch(value: string) {
|
|
134
|
+
setSearch(value);
|
|
135
|
+
setPagination((current) => ({ ...current, pageIndex: 0 }));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const isSection = layout === "section";
|
|
139
|
+
|
|
140
|
+
function renderRegion(id: string, content: React.ReactNode) {
|
|
141
|
+
return topology ? (
|
|
142
|
+
<TopologyRegion as="div" id={id} topology={topology}>
|
|
143
|
+
{content}
|
|
144
|
+
</TopologyRegion>
|
|
145
|
+
) : (
|
|
146
|
+
content
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const header =
|
|
151
|
+
title || description || primaryAction ? (
|
|
152
|
+
<header
|
|
153
|
+
className={cn(
|
|
154
|
+
"flex flex-col gap-4 pb-4 sm:flex-row sm:items-center sm:justify-between",
|
|
155
|
+
showHeaderDivider && "border-b",
|
|
156
|
+
isSection && "px-4 py-3",
|
|
157
|
+
topologyIds?.header === "27.1.1" && "h-12 pb-0",
|
|
158
|
+
)}
|
|
159
|
+
>
|
|
160
|
+
<div className="min-w-0">
|
|
161
|
+
{title ? (
|
|
162
|
+
<h2 className={cn("font-semibold tracking-tight", isSection ? "text-sm" : "text-2xl")}>{title}</h2>
|
|
163
|
+
) : null}
|
|
164
|
+
{description ? <p className="mt-1 text-sm text-muted-foreground">{description}</p> : null}
|
|
165
|
+
</div>
|
|
166
|
+
{primaryAction ? <div className="flex shrink-0 items-center gap-2 sm:justify-end">{primaryAction}</div> : null}
|
|
167
|
+
</header>
|
|
168
|
+
) : null;
|
|
169
|
+
|
|
170
|
+
const searchRegion = withToolbar ? (
|
|
171
|
+
<div className={cn(searchTopSpacing && "pt-16", isSection && "border-b p-2")}>
|
|
172
|
+
<DataTableToolbar
|
|
173
|
+
columns={table
|
|
174
|
+
.getAllColumns()
|
|
175
|
+
.filter((column) => column.getCanHide())
|
|
176
|
+
.map((column) => ({
|
|
177
|
+
id: column.id,
|
|
178
|
+
label: typeof column.columnDef.header === "string" ? column.columnDef.header : column.id,
|
|
179
|
+
onVisibleChange: (visible: boolean) => column.toggleVisibility(visible),
|
|
180
|
+
visible: column.getIsVisible(),
|
|
181
|
+
}))}
|
|
182
|
+
filters={toolbarFilters}
|
|
183
|
+
onSearchChange={updateSearch}
|
|
184
|
+
search={search}
|
|
185
|
+
searchPlaceholder={searchPlaceholder}
|
|
186
|
+
topology={topology}
|
|
187
|
+
topologyIds={{ columnFilter: topologyIds?.columnFilter, searchBar: topologyIds?.searchBar }}
|
|
188
|
+
filterOptions={filterOptions}
|
|
189
|
+
filterValue={filterValue}
|
|
190
|
+
onFilterChange={(value) => {
|
|
191
|
+
setFilterValue(value);
|
|
192
|
+
setPagination((current) => ({ ...current, pageIndex: 0 }));
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
) : null;
|
|
197
|
+
|
|
198
|
+
const content = (
|
|
199
|
+
<div
|
|
200
|
+
className={cn(
|
|
201
|
+
"overflow-x-auto overflow-y-hidden [scrollbar-width:none] [&::-webkit-scrollbar]:h-0",
|
|
202
|
+
!isSection && "rounded-md border bg-card shadow-sm",
|
|
203
|
+
)}
|
|
204
|
+
>
|
|
205
|
+
<Table>
|
|
206
|
+
<TableHeader
|
|
207
|
+
className="bg-muted data-[ito-highlighted=true]:outline data-[ito-highlighted=true]:outline-2 data-[ito-highlighted=true]:outline-violet-600"
|
|
208
|
+
{...(topology && topologyIds?.rowHeader ? topology.regionProps(topologyIds.rowHeader) : {})}
|
|
209
|
+
>
|
|
210
|
+
{table.getHeaderGroups().map((headerGroup) => (
|
|
211
|
+
<TableRow key={headerGroup.id}>
|
|
212
|
+
{showSerialNumber ? (
|
|
213
|
+
<TableHead className="h-11 w-12 min-w-12 max-w-12 text-center text-xs font-semibold uppercase tracking-wide text-muted-foreground">
|
|
214
|
+
#
|
|
215
|
+
</TableHead>
|
|
216
|
+
) : null}
|
|
217
|
+
{headerGroup.headers.map((header) => (
|
|
218
|
+
<TableHead
|
|
219
|
+
className={cn(
|
|
220
|
+
"h-11 text-xs font-semibold uppercase tracking-wide text-muted-foreground",
|
|
221
|
+
getUtilityColumnClass(header.column.id),
|
|
222
|
+
)}
|
|
223
|
+
key={header.id}
|
|
224
|
+
colSpan={header.colSpan}
|
|
225
|
+
>
|
|
226
|
+
{header.isPlaceholder ? null : header.column.getCanSort() ? (
|
|
227
|
+
<button
|
|
228
|
+
className="flex items-center gap-1 text-left font-medium hover:text-foreground"
|
|
229
|
+
onClick={header.column.getToggleSortingHandler()}
|
|
230
|
+
>
|
|
231
|
+
<FlexRender header={header} />
|
|
232
|
+
</button>
|
|
233
|
+
) : (
|
|
234
|
+
<FlexRender header={header} />
|
|
235
|
+
)}
|
|
236
|
+
</TableHead>
|
|
237
|
+
))}
|
|
238
|
+
</TableRow>
|
|
239
|
+
))}
|
|
240
|
+
</TableHeader>
|
|
241
|
+
<TableBody
|
|
242
|
+
className="data-[ito-highlighted=true]:outline data-[ito-highlighted=true]:outline-2 data-[ito-highlighted=true]:outline-violet-600"
|
|
243
|
+
{...(topology && topologyIds?.rows ? topology.regionProps(topologyIds.rows) : {})}
|
|
244
|
+
>
|
|
245
|
+
{table.getRowModel().rows.length ? (
|
|
246
|
+
table.getRowModel().rows.map((row, rowIndex) => (
|
|
247
|
+
<TableRow className="hover:bg-muted/60" key={row.id}>
|
|
248
|
+
{showSerialNumber ? (
|
|
249
|
+
<TableCell className="w-12 min-w-12 max-w-12 text-center tabular-nums text-muted-foreground">
|
|
250
|
+
{pagination.pageIndex * pagination.pageSize + rowIndex + 1}
|
|
251
|
+
</TableCell>
|
|
252
|
+
) : null}
|
|
253
|
+
{row.getVisibleCells().map((cell) => (
|
|
254
|
+
<TableCell className={getUtilityColumnClass(cell.column.id)} key={cell.id}>
|
|
255
|
+
<FlexRender cell={cell} />
|
|
256
|
+
</TableCell>
|
|
257
|
+
))}
|
|
258
|
+
</TableRow>
|
|
259
|
+
))
|
|
260
|
+
) : (
|
|
261
|
+
<TableRow>
|
|
262
|
+
<TableCell
|
|
263
|
+
className="h-36 text-center text-sm text-muted-foreground"
|
|
264
|
+
colSpan={table.getVisibleLeafColumns().length + (showSerialNumber ? 1 : 0)}
|
|
265
|
+
>
|
|
266
|
+
{emptyMessage}
|
|
267
|
+
</TableCell>
|
|
268
|
+
</TableRow>
|
|
269
|
+
)}
|
|
270
|
+
</TableBody>
|
|
271
|
+
</Table>
|
|
272
|
+
</div>
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
const paginationContent = withPagination ? (
|
|
276
|
+
<DataTablePagination
|
|
277
|
+
firstRow={firstRow}
|
|
278
|
+
itemLabel={itemLabel}
|
|
279
|
+
lastRow={lastRow}
|
|
280
|
+
onPageChange={(page) => table.setPageIndex(page - 1)}
|
|
281
|
+
onPageSizeChange={(pageSize) => setPagination({ pageIndex: 0, pageSize })}
|
|
282
|
+
page={pagination.pageIndex + 1}
|
|
283
|
+
pageSize={pagination.pageSize}
|
|
284
|
+
pageSizeOptions={pageSizeOptions}
|
|
285
|
+
totalItems={visibleData.length}
|
|
286
|
+
totalPages={pageCount}
|
|
287
|
+
topology={topology}
|
|
288
|
+
topologyIds={{ pageNavigation: topologyIds?.pageNavigation, pageSize: topologyIds?.pageSize }}
|
|
289
|
+
/>
|
|
290
|
+
) : null;
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<section
|
|
294
|
+
className={cn(
|
|
295
|
+
isSection ? "w-full" : pageWidth === "wide" ? "mx-auto w-full lg:w-[90%]" : "w-full",
|
|
296
|
+
isSection ? "overflow-hidden rounded-lg border bg-card" : "space-y-4",
|
|
297
|
+
)}
|
|
298
|
+
>
|
|
299
|
+
{header ? renderRegion(topologyIds?.header ?? "data-table-header", header) : null}
|
|
300
|
+
{searchRegion ? renderRegion(topologyIds?.search ?? "data-table-search", searchRegion) : null}
|
|
301
|
+
{renderRegion(topologyIds?.content ?? "data-table-content", content)}
|
|
302
|
+
{summary}
|
|
303
|
+
{tableFooter ? <footer className="border-t p-3">{tableFooter}</footer> : null}
|
|
304
|
+
{paginationContent ? renderRegion(topologyIds?.pagination ?? "data-table-pagination", paginationContent) : null}
|
|
305
|
+
</section>
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function getUtilityColumnClass(columnId: string) {
|
|
310
|
+
return columnId === "action" || columnId === "actions"
|
|
311
|
+
? "w-14 min-w-14 max-w-14 text-center [&>button]:mx-auto [&>div]:mx-auto [&>svg]:mx-auto"
|
|
312
|
+
: undefined;
|
|
313
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Funnel } from 'lucide-react'
|
|
2
|
+
import { DropdownMenu, DropdownMenuCheckboxItem } from '@devxcrew/react-ui/components/dropdown-menu'
|
|
3
|
+
import { DataTableIconMenuTrigger } from './data-table-icon-menu-trigger'
|
|
4
|
+
import { DataTableMenuContent, dataTableMenuOptionClass } from './data-table-menu-content'
|
|
5
|
+
|
|
6
|
+
export type DataTableFilterOption<TValue extends string> = {
|
|
7
|
+
checked: boolean
|
|
8
|
+
label: string
|
|
9
|
+
value: TValue
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function DataTableFilterMenu<TValue extends string>({
|
|
13
|
+
activeCount = 0,
|
|
14
|
+
clearLabel = 'Clear',
|
|
15
|
+
label = 'Filters',
|
|
16
|
+
onClear,
|
|
17
|
+
onSelect,
|
|
18
|
+
options,
|
|
19
|
+
title = 'Filter options',
|
|
20
|
+
}: {
|
|
21
|
+
activeCount?: number
|
|
22
|
+
clearLabel?: string
|
|
23
|
+
label?: string
|
|
24
|
+
onClear: () => void
|
|
25
|
+
onSelect: (value: TValue) => void
|
|
26
|
+
options: DataTableFilterOption<TValue>[]
|
|
27
|
+
title?: string
|
|
28
|
+
}) {
|
|
29
|
+
return (
|
|
30
|
+
<DropdownMenu>
|
|
31
|
+
<DataTableIconMenuTrigger active={activeCount > 0} label={label}>
|
|
32
|
+
<Funnel />
|
|
33
|
+
</DataTableIconMenuTrigger>
|
|
34
|
+
<DataTableMenuContent actionLabel={clearLabel} onAction={onClear} title={title}>
|
|
35
|
+
{options.map((option) => (
|
|
36
|
+
<DropdownMenuCheckboxItem
|
|
37
|
+
checked={option.checked}
|
|
38
|
+
className={dataTableMenuOptionClass}
|
|
39
|
+
key={option.value}
|
|
40
|
+
onCheckedChange={() => onSelect(option.value)}
|
|
41
|
+
>
|
|
42
|
+
{option.label}
|
|
43
|
+
</DropdownMenuCheckboxItem>
|
|
44
|
+
))}
|
|
45
|
+
</DataTableMenuContent>
|
|
46
|
+
</DropdownMenu>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { Button } from '@devxcrew/react-ui/components/button'
|
|
3
|
+
import { DropdownMenuTrigger } from '@devxcrew/react-ui/components/dropdown-menu'
|
|
4
|
+
import {
|
|
5
|
+
Tooltip,
|
|
6
|
+
TooltipContent,
|
|
7
|
+
TooltipProvider,
|
|
8
|
+
TooltipTrigger,
|
|
9
|
+
} from '@devxcrew/react-ui/components/tooltip'
|
|
10
|
+
|
|
11
|
+
export function DataTableIconMenuTrigger({
|
|
12
|
+
active = false,
|
|
13
|
+
children,
|
|
14
|
+
label,
|
|
15
|
+
}: {
|
|
16
|
+
active?: boolean
|
|
17
|
+
children: ReactNode
|
|
18
|
+
label: string
|
|
19
|
+
}) {
|
|
20
|
+
return (
|
|
21
|
+
<TooltipProvider>
|
|
22
|
+
<Tooltip>
|
|
23
|
+
<DropdownMenuTrigger
|
|
24
|
+
render={
|
|
25
|
+
<TooltipTrigger
|
|
26
|
+
render={
|
|
27
|
+
<Button aria-label={label} className="relative" size="icon-sm" variant="outline" />
|
|
28
|
+
}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
{active ? (
|
|
32
|
+
<span
|
|
33
|
+
aria-hidden="true"
|
|
34
|
+
className="absolute top-1 right-1 size-1.5 rounded-full bg-primary"
|
|
35
|
+
/>
|
|
36
|
+
) : null}
|
|
37
|
+
</TooltipTrigger>
|
|
38
|
+
}
|
|
39
|
+
/>
|
|
40
|
+
<TooltipContent>{label}</TooltipContent>
|
|
41
|
+
</Tooltip>
|
|
42
|
+
</TooltipProvider>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { DropdownMenuContent } from '@devxcrew/react-ui/components/dropdown-menu'
|
|
3
|
+
|
|
4
|
+
export function DataTableMenuContent({
|
|
5
|
+
actionLabel,
|
|
6
|
+
children,
|
|
7
|
+
onAction,
|
|
8
|
+
title,
|
|
9
|
+
}: {
|
|
10
|
+
actionLabel: string
|
|
11
|
+
children: ReactNode
|
|
12
|
+
onAction: () => void
|
|
13
|
+
title: string
|
|
14
|
+
}) {
|
|
15
|
+
return (
|
|
16
|
+
<DropdownMenuContent align="end" className="w-56 p-0">
|
|
17
|
+
<div className="flex items-center justify-between gap-4 border-b px-3 py-2.5">
|
|
18
|
+
<span className="text-sm font-medium">{title}</span>
|
|
19
|
+
<button
|
|
20
|
+
className="text-sm text-muted-foreground transition-colors hover:text-foreground"
|
|
21
|
+
onClick={onAction}
|
|
22
|
+
type="button"
|
|
23
|
+
>
|
|
24
|
+
{actionLabel}
|
|
25
|
+
</button>
|
|
26
|
+
</div>
|
|
27
|
+
<div className="grid gap-1 p-2">{children}</div>
|
|
28
|
+
</DropdownMenuContent>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const dataTableMenuOptionClass = 'min-h-10 py-2.5 pl-3'
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
|
2
|
+
import { Button } from '@devxcrew/react-ui/components/button';
|
|
3
|
+
import {
|
|
4
|
+
Select,
|
|
5
|
+
SelectContent,
|
|
6
|
+
SelectGroup,
|
|
7
|
+
SelectItem,
|
|
8
|
+
SelectTrigger,
|
|
9
|
+
SelectValue,
|
|
10
|
+
} from '@devxcrew/react-ui/components/select';
|
|
11
|
+
import { cn } from '@devxcrew/react-ui/lib/utils';
|
|
12
|
+
import { TopologyRegion, type InterfaceTopologyController } from '@devxcrew/react-ui/features/interface-topology';
|
|
13
|
+
|
|
14
|
+
export function DataTablePagination({
|
|
15
|
+
className,
|
|
16
|
+
firstRow,
|
|
17
|
+
itemLabel,
|
|
18
|
+
lastRow,
|
|
19
|
+
onPageChange,
|
|
20
|
+
onPageSizeChange,
|
|
21
|
+
page,
|
|
22
|
+
pageSize,
|
|
23
|
+
pageSizeOptions,
|
|
24
|
+
totalItems,
|
|
25
|
+
totalPages,
|
|
26
|
+
topology,
|
|
27
|
+
topologyIds,
|
|
28
|
+
}: {
|
|
29
|
+
className?: string;
|
|
30
|
+
firstRow: number;
|
|
31
|
+
itemLabel: string;
|
|
32
|
+
lastRow: number;
|
|
33
|
+
onPageChange: (page: number) => void;
|
|
34
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
35
|
+
page: number;
|
|
36
|
+
pageSize: number;
|
|
37
|
+
pageSizeOptions: readonly number[];
|
|
38
|
+
totalItems: number;
|
|
39
|
+
totalPages: number;
|
|
40
|
+
topology?: InterfaceTopologyController;
|
|
41
|
+
topologyIds?: { pageSize?: string; pageNavigation?: string };
|
|
42
|
+
}) {
|
|
43
|
+
const pageSizeControl = (
|
|
44
|
+
<div className="flex flex-wrap items-center gap-3 text-muted-foreground">
|
|
45
|
+
<span>
|
|
46
|
+
Total {itemLabel}: <strong className="font-semibold text-foreground">{totalItems}</strong>
|
|
47
|
+
</span>
|
|
48
|
+
<span>Rows per page</span>
|
|
49
|
+
<Select
|
|
50
|
+
items={pageSizeOptions.map((size) => ({ label: String(size), value: String(size) }))}
|
|
51
|
+
onValueChange={(value) => onPageSizeChange(Number(value))}
|
|
52
|
+
value={String(pageSize)}
|
|
53
|
+
>
|
|
54
|
+
<SelectTrigger className="w-20" size="sm">
|
|
55
|
+
<SelectValue />
|
|
56
|
+
</SelectTrigger>
|
|
57
|
+
<SelectContent side="top">
|
|
58
|
+
<SelectGroup>
|
|
59
|
+
{pageSizeOptions.map((size) => (
|
|
60
|
+
<SelectItem key={size} value={String(size)}>
|
|
61
|
+
{size}
|
|
62
|
+
</SelectItem>
|
|
63
|
+
))}
|
|
64
|
+
</SelectGroup>
|
|
65
|
+
</SelectContent>
|
|
66
|
+
</Select>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
const navigation = (
|
|
70
|
+
<div className="flex flex-wrap items-center gap-1 lg:justify-end">
|
|
71
|
+
<span className="mr-2 whitespace-nowrap text-muted-foreground">
|
|
72
|
+
Showing {firstRow} to {lastRow} of {totalItems}
|
|
73
|
+
</span>
|
|
74
|
+
<Button
|
|
75
|
+
className="px-2 text-muted-foreground"
|
|
76
|
+
disabled={page <= 1}
|
|
77
|
+
onClick={() => onPageChange(page - 1)}
|
|
78
|
+
size="sm"
|
|
79
|
+
variant="ghost"
|
|
80
|
+
>
|
|
81
|
+
<ChevronLeft />
|
|
82
|
+
Previous
|
|
83
|
+
</Button>
|
|
84
|
+
{buildPageItems(page, totalPages).map((item, index) =>
|
|
85
|
+
item === 'ellipsis' ? (
|
|
86
|
+
<span className="px-1.5 text-muted-foreground" key={`ellipsis-${index}`}>
|
|
87
|
+
…
|
|
88
|
+
</span>
|
|
89
|
+
) : (
|
|
90
|
+
<Button
|
|
91
|
+
className="min-w-8 px-2"
|
|
92
|
+
key={item}
|
|
93
|
+
onClick={() => onPageChange(item)}
|
|
94
|
+
size="sm"
|
|
95
|
+
variant={item === page ? 'default' : 'ghost'}
|
|
96
|
+
>
|
|
97
|
+
{item}
|
|
98
|
+
</Button>
|
|
99
|
+
),
|
|
100
|
+
)}
|
|
101
|
+
<Button
|
|
102
|
+
className="px-2 text-muted-foreground"
|
|
103
|
+
disabled={page >= totalPages}
|
|
104
|
+
onClick={() => onPageChange(page + 1)}
|
|
105
|
+
size="sm"
|
|
106
|
+
variant="ghost"
|
|
107
|
+
>
|
|
108
|
+
Next
|
|
109
|
+
<ChevronRight />
|
|
110
|
+
</Button>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<footer
|
|
116
|
+
className={cn(
|
|
117
|
+
'flex flex-col gap-3 rounded-md border bg-card px-4 py-2 text-sm shadow-sm lg:flex-row lg:items-center lg:justify-between',
|
|
118
|
+
className,
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{topology && topologyIds?.pageSize ? (
|
|
122
|
+
<TopologyRegion as="div" id={topologyIds.pageSize} topology={topology}>
|
|
123
|
+
{pageSizeControl}
|
|
124
|
+
</TopologyRegion>
|
|
125
|
+
) : (
|
|
126
|
+
pageSizeControl
|
|
127
|
+
)}
|
|
128
|
+
{topology && topologyIds?.pageNavigation ? (
|
|
129
|
+
<TopologyRegion as="div" id={topologyIds.pageNavigation} topology={topology}>
|
|
130
|
+
{navigation}
|
|
131
|
+
</TopologyRegion>
|
|
132
|
+
) : (
|
|
133
|
+
navigation
|
|
134
|
+
)}
|
|
135
|
+
</footer>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function buildPageItems(page: number, totalPages: number): Array<number | 'ellipsis'> {
|
|
140
|
+
if (totalPages <= 5) return Array.from({ length: totalPages }, (_, index) => index + 1);
|
|
141
|
+
const candidates = [1, page - 1, page, page + 1, totalPages];
|
|
142
|
+
const pages = [...new Set(candidates.filter((item) => item >= 1 && item <= totalPages))];
|
|
143
|
+
const result: Array<number | 'ellipsis'> = [];
|
|
144
|
+
pages.forEach((item, index) => {
|
|
145
|
+
if (index > 0 && item - pages[index - 1]! > 1) result.push('ellipsis');
|
|
146
|
+
result.push(item);
|
|
147
|
+
});
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { Ellipsis } from 'lucide-react'
|
|
3
|
+
import { Button } from '@devxcrew/react-ui/components/button'
|
|
4
|
+
import {
|
|
5
|
+
DropdownMenu,
|
|
6
|
+
DropdownMenuContent,
|
|
7
|
+
DropdownMenuItem,
|
|
8
|
+
DropdownMenuSeparator,
|
|
9
|
+
DropdownMenuTrigger,
|
|
10
|
+
} from '@devxcrew/react-ui/components/dropdown-menu'
|
|
11
|
+
|
|
12
|
+
export type DataTableRowAction = {
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
icon?: ReactNode
|
|
15
|
+
id: string
|
|
16
|
+
label: string
|
|
17
|
+
onSelect: () => void
|
|
18
|
+
separatorBefore?: boolean
|
|
19
|
+
tone?: 'default' | 'destructive'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function DataTableRowActions({
|
|
23
|
+
actions,
|
|
24
|
+
label,
|
|
25
|
+
}: {
|
|
26
|
+
actions: DataTableRowAction[]
|
|
27
|
+
label: string
|
|
28
|
+
}) {
|
|
29
|
+
if (!actions.length) return null
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<DropdownMenu>
|
|
33
|
+
<DropdownMenuTrigger render={<Button aria-label={label} size="icon-sm" variant="outline" />}>
|
|
34
|
+
<Ellipsis />
|
|
35
|
+
</DropdownMenuTrigger>
|
|
36
|
+
<DropdownMenuContent align="end" className="w-44">
|
|
37
|
+
{actions.map((action, index) => (
|
|
38
|
+
<div key={action.id}>
|
|
39
|
+
{action.separatorBefore && index > 0 ? <DropdownMenuSeparator /> : null}
|
|
40
|
+
<DropdownMenuItem
|
|
41
|
+
disabled={action.disabled}
|
|
42
|
+
onClick={action.onSelect}
|
|
43
|
+
variant={action.tone}
|
|
44
|
+
>
|
|
45
|
+
{action.icon}
|
|
46
|
+
{action.label}
|
|
47
|
+
</DropdownMenuItem>
|
|
48
|
+
</div>
|
|
49
|
+
))}
|
|
50
|
+
</DropdownMenuContent>
|
|
51
|
+
</DropdownMenu>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CheckCircle2, Minus, XCircle } from 'lucide-react'
|
|
2
|
+
import { cn } from '@devxcrew/react-ui/lib/utils'
|
|
3
|
+
|
|
4
|
+
export type DataTableStatusTone = 'danger' | 'info' | 'neutral' | 'success' | 'warning'
|
|
5
|
+
|
|
6
|
+
const toneClasses: Record<DataTableStatusTone, string> = {
|
|
7
|
+
danger:
|
|
8
|
+
'border-red-200 bg-red-50 text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300',
|
|
9
|
+
info: 'border-blue-200 bg-blue-50 text-blue-700 dark:border-blue-900 dark:bg-blue-950/40 dark:text-blue-300',
|
|
10
|
+
neutral: 'border-border bg-muted/50 text-muted-foreground',
|
|
11
|
+
success:
|
|
12
|
+
'border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300',
|
|
13
|
+
warning:
|
|
14
|
+
'border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950/40 dark:text-amber-300',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function DataTableStatus({
|
|
18
|
+
className,
|
|
19
|
+
label,
|
|
20
|
+
showIcon = true,
|
|
21
|
+
tone = 'neutral',
|
|
22
|
+
}: {
|
|
23
|
+
className?: string
|
|
24
|
+
label: string
|
|
25
|
+
showIcon?: boolean
|
|
26
|
+
tone?: DataTableStatusTone
|
|
27
|
+
}) {
|
|
28
|
+
const Icon = tone === 'danger' ? XCircle : tone === 'neutral' ? Minus : CheckCircle2
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<span
|
|
32
|
+
className={cn(
|
|
33
|
+
'inline-flex h-6 items-center gap-1 rounded-md border px-2 text-[11px] font-medium',
|
|
34
|
+
toneClasses[tone],
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
>
|
|
38
|
+
{showIcon ? <Icon className="size-3" aria-hidden="true" /> : null}
|
|
39
|
+
{label}
|
|
40
|
+
</span>
|
|
41
|
+
)
|
|
42
|
+
}
|