@gntik-ai/blocks 0.0.0-stage → 0.5.0
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/dist/index.d.ts +3494 -0
- package/dist/index.js +14911 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -3
- package/src/ai/AssistantCardGrid/AssistantCardGrid.test.tsx +32 -0
- package/src/ai/AssistantCardGrid/AssistantCardGrid.tsx +98 -0
- package/src/ai/AssistantCardGrid/block.meta.ts +10 -0
- package/src/ai/AssistantCardGrid/fixtures.ts +72 -0
- package/src/ai/EvaluationScorecard/EvaluationScorecard.test.tsx +39 -0
- package/src/ai/EvaluationScorecard/EvaluationScorecard.tsx +233 -0
- package/src/ai/EvaluationScorecard/block.meta.ts +10 -0
- package/src/ai/EvaluationScorecard/fixtures.ts +79 -0
- package/src/ai/ModelKeysList/ModelKeysList.test.tsx +44 -0
- package/src/ai/ModelKeysList/ModelKeysList.tsx +203 -0
- package/src/ai/ModelKeysList/block.meta.ts +10 -0
- package/src/ai/ModelKeysList/fixtures.ts +44 -0
- package/src/ai/PromptEditor/PromptEditor.test.tsx +97 -0
- package/src/ai/PromptEditor/PromptEditor.tsx +202 -0
- package/src/ai/PromptEditor/block.meta.ts +10 -0
- package/src/ai/PromptEditor/examples/controlled-variables.tsx +23 -0
- package/src/ai/PromptEditor/fixtures.ts +12 -0
- package/src/ai/TokenCostCard/TokenCostCard.test.tsx +36 -0
- package/src/ai/TokenCostCard/TokenCostCard.tsx +130 -0
- package/src/ai/TokenCostCard/block.meta.ts +9 -0
- package/src/ai/TokenCostCard/fixtures.ts +18 -0
- package/src/ai/TraceWaterfall/TraceWaterfall.test.tsx +119 -0
- package/src/ai/TraceWaterfall/TraceWaterfall.tsx +317 -0
- package/src/ai/TraceWaterfall/block.meta.ts +10 -0
- package/src/ai/TraceWaterfall/examples/no-details.tsx +6 -0
- package/src/ai/TraceWaterfall/examples/running.tsx +16 -0
- package/src/ai/TraceWaterfall/fixtures.ts +133 -0
- package/src/ai/TraceWaterfall/span-details.tsx +51 -0
- package/src/ai/index.ts +13 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.test.tsx +209 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +211 -0
- package/src/auth/ForgotPasswordForm/block.meta.ts +10 -0
- package/src/auth/ForgotPasswordForm/examples/UsernameOrEmail.tsx +24 -0
- package/src/auth/MfaChallenge/MfaChallenge.test.tsx +35 -0
- package/src/auth/MfaChallenge/MfaChallenge.tsx +170 -0
- package/src/auth/MfaChallenge/block.meta.ts +9 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.test.tsx +27 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +100 -0
- package/src/auth/ResetPasswordForm/block.meta.ts +10 -0
- package/src/auth/SignInForm/SignInForm.test.tsx +222 -0
- package/src/auth/SignInForm/SignInForm.tsx +226 -0
- package/src/auth/SignInForm/block.meta.ts +22 -0
- package/src/auth/SignInForm/examples/Username.tsx +26 -0
- package/src/auth/SignUpForm/SignUpForm.test.tsx +33 -0
- package/src/auth/SignUpForm/SignUpForm.tsx +154 -0
- package/src/auth/SignUpForm/block.meta.ts +9 -0
- package/src/auth/SsoButtons/SsoButtons.test.tsx +23 -0
- package/src/auth/SsoButtons/SsoButtons.tsx +52 -0
- package/src/auth/SsoButtons/block.meta.ts +9 -0
- package/src/auth/SsoButtons/fixtures.ts +15 -0
- package/src/auth/index.ts +15 -0
- package/src/auth/shared.tsx +113 -0
- package/src/billing/CostBreakdown/CostBreakdown.test.tsx +24 -0
- package/src/billing/CostBreakdown/CostBreakdown.tsx +95 -0
- package/src/billing/CostBreakdown/block.meta.ts +10 -0
- package/src/billing/CostBreakdown/fixtures.ts +9 -0
- package/src/billing/InvoiceTable/InvoiceTable.test.tsx +29 -0
- package/src/billing/InvoiceTable/InvoiceTable.tsx +130 -0
- package/src/billing/InvoiceTable/block.meta.ts +10 -0
- package/src/billing/InvoiceTable/fixtures.ts +38 -0
- package/src/billing/PaymentMethodCard/PaymentMethodCard.test.tsx +28 -0
- package/src/billing/PaymentMethodCard/PaymentMethodCard.tsx +103 -0
- package/src/billing/PaymentMethodCard/block.meta.ts +10 -0
- package/src/billing/PaymentMethodCard/fixtures.ts +12 -0
- package/src/billing/PlanCard/PlanCard.baseline.test.tsx +26 -0
- package/src/billing/PlanCard/PlanCard.summary.test.tsx +227 -0
- package/src/billing/PlanCard/PlanCard.test.tsx +27 -0
- package/src/billing/PlanCard/PlanCard.tsx +140 -0
- package/src/billing/PlanCard/PlanSummary.tsx +101 -0
- package/src/billing/PlanCard/README.md +23 -0
- package/src/billing/PlanCard/__snapshots__/PlanCard.baseline.test.tsx.snap +5 -0
- package/src/billing/PlanCard/block.meta.ts +60 -0
- package/src/billing/PlanCard/examples/SummaryActionsOnly.tsx +12 -0
- package/src/billing/PlanCard/examples/SummaryFeaturesOnly.tsx +14 -0
- package/src/billing/PlanCard/examples/SummaryFull.tsx +28 -0
- package/src/billing/PlanCard/examples/SummaryMinimal.tsx +5 -0
- package/src/billing/PlanCard/examples/SummaryPriceOnly.tsx +15 -0
- package/src/billing/PlanCard/examples/SummaryRenewalOnly.tsx +14 -0
- package/src/billing/PlanCard/examples/SummaryUnassigned.tsx +5 -0
- package/src/billing/PlanCard/examples/SummaryUnassignedNoLabel.tsx +5 -0
- package/src/billing/PlanCard/examples/SummaryZeroPrice.tsx +15 -0
- package/src/billing/PlanCard/fixtures.ts +19 -0
- package/src/billing/PlanDefinitionCard/PlanDefinitionCard.test.tsx +111 -0
- package/src/billing/PlanDefinitionCard/PlanDefinitionCard.tsx +86 -0
- package/src/billing/PlanDefinitionCard/README.md +29 -0
- package/src/billing/PlanDefinitionCard/block.meta.ts +46 -0
- package/src/billing/PlanDefinitionCard/examples/Compact.tsx +23 -0
- package/src/billing/PlanDefinitionCard/examples/Full.tsx +23 -0
- package/src/billing/PlanDefinitionCard/fixtures.ts +12 -0
- package/src/billing/QuotaMeters/QuotaMeters.test.tsx +23 -0
- package/src/billing/QuotaMeters/QuotaMeters.tsx +92 -0
- package/src/billing/QuotaMeters/block.meta.ts +10 -0
- package/src/billing/QuotaMeters/fixtures.ts +9 -0
- package/src/billing/SpendVsBudget/SpendVsBudget.test.tsx +24 -0
- package/src/billing/SpendVsBudget/SpendVsBudget.tsx +105 -0
- package/src/billing/SpendVsBudget/block.meta.ts +10 -0
- package/src/billing/SpendVsBudget/fixtures.ts +18 -0
- package/src/billing/format.ts +42 -0
- package/src/billing/index.ts +21 -0
- package/src/builders/CodePanel/CodePanel.test.tsx +280 -0
- package/src/builders/CodePanel/CodePanel.tsx +239 -0
- package/src/builders/CodePanel/block.meta.ts +10 -0
- package/src/builders/CodePanel/examples/controlled.tsx +15 -0
- package/src/builders/CodePanel/examples/diagnostics.tsx +40 -0
- package/src/builders/CodePanel/fixtures.ts +95 -0
- package/src/builders/CodePanel/marker-store.ts +90 -0
- package/src/builders/CodePanel/markers.ts +62 -0
- package/src/builders/FlowBuilder/FlowBuilder.test.tsx +480 -0
- package/src/builders/FlowBuilder/FlowBuilder.tsx +343 -0
- package/src/builders/FlowBuilder/block.meta.ts +20 -0
- package/src/builders/FlowBuilder/connections.ts +67 -0
- package/src/builders/FlowBuilder/decorated-nodes.ts +80 -0
- package/src/builders/FlowBuilder/examples/extensions.tsx +120 -0
- package/src/builders/FlowBuilder/extensions.ts +37 -0
- package/src/builders/FlowBuilder/fixtures.ts +80 -0
- package/src/builders/FlowBuilder/parts.tsx +196 -0
- package/src/builders/FlowBuilder/problems.tsx +40 -0
- package/src/builders/LogViewer/LogViewer.test.tsx +97 -0
- package/src/builders/LogViewer/LogViewer.tsx +253 -0
- package/src/builders/LogViewer/block.meta.ts +10 -0
- package/src/builders/LogViewer/fixtures.ts +49 -0
- package/src/builders/index.ts +15 -0
- package/src/data-display/ActivityFeed/ActivityFeed.test.tsx +62 -0
- package/src/data-display/ActivityFeed/ActivityFeed.tsx +118 -0
- package/src/data-display/ActivityFeed/block.meta.ts +10 -0
- package/src/data-display/ActivityFeed/fixtures.ts +29 -0
- package/src/data-display/ChartCard/ChartCard.ranges.test.tsx +282 -0
- package/src/data-display/ChartCard/ChartCard.test.tsx +54 -0
- package/src/data-display/ChartCard/ChartCard.tsx +218 -0
- package/src/data-display/ChartCard/block.meta.ts +10 -0
- package/src/data-display/ChartCard/examples/custom-ranges.tsx +37 -0
- package/src/data-display/ChartCard/examples/heatmap.tsx +20 -0
- package/src/data-display/ChartCard/examples/toolbar-owned-range.tsx +34 -0
- package/src/data-display/ChartCard/fixtures.ts +82 -0
- package/src/data-display/CommentThread/CommentThread.test.tsx +29 -0
- package/src/data-display/CommentThread/CommentThread.tsx +120 -0
- package/src/data-display/CommentThread/block.meta.ts +10 -0
- package/src/data-display/CommentThread/fixtures.ts +28 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.test.tsx +28 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +120 -0
- package/src/data-display/DescriptionListCard/block.meta.ts +9 -0
- package/src/data-display/DescriptionListCard/fixtures.ts +12 -0
- package/src/data-display/KpiRow/KpiRow.test.tsx +29 -0
- package/src/data-display/KpiRow/KpiRow.tsx +101 -0
- package/src/data-display/KpiRow/block.meta.ts +10 -0
- package/src/data-display/KpiRow/fixtures.ts +34 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.test.tsx +22 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.tsx +98 -0
- package/src/data-display/ResourceCardGrid/block.meta.ts +10 -0
- package/src/data-display/ResourceCardGrid/fixtures.ts +72 -0
- package/src/data-display/StatCard/StatCard.test.tsx +30 -0
- package/src/data-display/StatCard/StatCard.tsx +138 -0
- package/src/data-display/StatCard/block.meta.ts +10 -0
- package/src/data-display/StatCard/fixtures.ts +26 -0
- package/src/data-display/StatusTimeline/StatusTimeline.test.tsx +153 -0
- package/src/data-display/StatusTimeline/StatusTimeline.tsx +114 -0
- package/src/data-display/StatusTimeline/block.meta.ts +10 -0
- package/src/data-display/StatusTimeline/examples/Empty.tsx +6 -0
- package/src/data-display/StatusTimeline/fixtures.ts +62 -0
- package/src/data-display/index.ts +34 -0
- package/src/data-display/shared/TrendDelta.tsx +60 -0
- package/src/feedback/ConfirmDestructive/ConfirmDestructive.test.tsx +47 -0
- package/src/feedback/ConfirmDestructive/ConfirmDestructive.tsx +145 -0
- package/src/feedback/ConfirmDestructive/block.meta.ts +10 -0
- package/src/feedback/EmptyStates/EmptyStates.test.tsx +48 -0
- package/src/feedback/EmptyStates/EmptyStates.tsx +191 -0
- package/src/feedback/EmptyStates/block.meta.ts +10 -0
- package/src/feedback/EmptyStates/fixtures.ts +6 -0
- package/src/feedback/ErrorPanel/ErrorPanel.test.tsx +37 -0
- package/src/feedback/ErrorPanel/ErrorPanel.tsx +146 -0
- package/src/feedback/ErrorPanel/block.meta.ts +10 -0
- package/src/feedback/InlineCallout/InlineCallout.test.tsx +33 -0
- package/src/feedback/InlineCallout/InlineCallout.tsx +81 -0
- package/src/feedback/InlineCallout/block.meta.ts +9 -0
- package/src/feedback/Skeletons/Skeletons.test.tsx +25 -0
- package/src/feedback/Skeletons/Skeletons.tsx +142 -0
- package/src/feedback/Skeletons/block.meta.ts +10 -0
- package/src/feedback/SystemBanner/SystemBanner.test.tsx +29 -0
- package/src/feedback/SystemBanner/SystemBanner.tsx +105 -0
- package/src/feedback/SystemBanner/block.meta.ts +9 -0
- package/src/feedback/index.ts +14 -0
- package/src/feedback/types.ts +13 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.test.tsx +36 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +197 -0
- package/src/forms/CreateApiKeyDialog/block.meta.ts +10 -0
- package/src/forms/CreateApiKeyDialog/fixtures.ts +31 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.test.tsx +339 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.tsx +193 -0
- package/src/forms/CredentialDisclosureDialog/block.meta.ts +10 -0
- package/src/forms/CredentialDisclosureDialog/examples/Fresh.tsx +32 -0
- package/src/forms/CredentialDisclosureDialog/examples/ResponseGating.tsx +69 -0
- package/src/forms/CredentialDisclosureDialog/examples/Stored.tsx +32 -0
- package/src/forms/CredentialDisclosureDialog/fixtures.ts +14 -0
- package/src/forms/DangerZone/ConfirmDestructiveDialog.tsx +101 -0
- package/src/forms/DangerZone/DangerZone.test.tsx +28 -0
- package/src/forms/DangerZone/DangerZone.tsx +86 -0
- package/src/forms/DangerZone/block.meta.ts +10 -0
- package/src/forms/DangerZone/fixtures.ts +36 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.test.tsx +26 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.tsx +83 -0
- package/src/forms/DateRangeFilter/block.meta.ts +9 -0
- package/src/forms/DialogWizard/DialogWizard.test.tsx +95 -0
- package/src/forms/DialogWizard/DialogWizard.tsx +39 -0
- package/src/forms/DialogWizard/block.meta.ts +10 -0
- package/src/forms/DialogWizard/examples/CreateResource.tsx +65 -0
- package/src/forms/DialogWizard/fixtures.ts +20 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.test.tsx +43 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.tsx +244 -0
- package/src/forms/FileUploadPanel/block.meta.ts +10 -0
- package/src/forms/FileUploadPanel/fixtures.ts +66 -0
- package/src/forms/FormSection/FormSection.test.tsx +34 -0
- package/src/forms/FormSection/FormSection.tsx +77 -0
- package/src/forms/FormSection/block.meta.ts +9 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.test.tsx +37 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +183 -0
- package/src/forms/InviteMembersDialog/block.meta.ts +10 -0
- package/src/forms/InviteMembersDialog/fixtures.ts +14 -0
- package/src/forms/SettingsRow/SettingsRow.test.tsx +50 -0
- package/src/forms/SettingsRow/SettingsRow.tsx +74 -0
- package/src/forms/SettingsRow/block.meta.ts +9 -0
- package/src/forms/ValidationSummary/ValidationSummary.test.tsx +46 -0
- package/src/forms/ValidationSummary/ValidationSummary.tsx +75 -0
- package/src/forms/ValidationSummary/block.meta.ts +9 -0
- package/src/forms/ValidationSummary/fixtures.ts +13 -0
- package/src/forms/index.ts +27 -0
- package/src/index.ts +14 -0
- package/src/marketing/ComparisonTable/ComparisonTable.test.tsx +69 -0
- package/src/marketing/ComparisonTable/ComparisonTable.tsx +245 -0
- package/src/marketing/ComparisonTable/block.meta.ts +10 -0
- package/src/marketing/ComparisonTable/examples/options.tsx +48 -0
- package/src/marketing/ComparisonTable/fixtures.ts +83 -0
- package/src/marketing/Faq/Faq.test.tsx +25 -0
- package/src/marketing/Faq/Faq.tsx +68 -0
- package/src/marketing/Faq/block.meta.ts +10 -0
- package/src/marketing/Faq/fixtures.ts +32 -0
- package/src/marketing/FeatureGrid/FeatureGrid.test.tsx +19 -0
- package/src/marketing/FeatureGrid/FeatureGrid.tsx +79 -0
- package/src/marketing/FeatureGrid/block.meta.ts +10 -0
- package/src/marketing/FeatureGrid/fixtures.ts +36 -0
- package/src/marketing/Hero/Hero.test.tsx +33 -0
- package/src/marketing/Hero/Hero.tsx +107 -0
- package/src/marketing/Hero/block.meta.ts +10 -0
- package/src/marketing/PricingTable/PricingTable.test.tsx +92 -0
- package/src/marketing/PricingTable/PricingTable.tsx +323 -0
- package/src/marketing/PricingTable/block.meta.ts +10 -0
- package/src/marketing/PricingTable/fixtures.ts +34 -0
- package/src/marketing/actions.tsx +40 -0
- package/src/marketing/index.ts +15 -0
- package/src/meta.ts +23 -0
- package/src/page-chrome/BulkActionBar/BulkActionBar.test.tsx +34 -0
- package/src/page-chrome/BulkActionBar/BulkActionBar.tsx +76 -0
- package/src/page-chrome/BulkActionBar/block.meta.ts +9 -0
- package/src/page-chrome/PageHeader/PageHeader.test.tsx +68 -0
- package/src/page-chrome/PageHeader/PageHeader.tsx +152 -0
- package/src/page-chrome/PageHeader/block.meta.ts +10 -0
- package/src/page-chrome/PageHeader/fixtures.ts +29 -0
- package/src/page-chrome/PageToolbar/PageToolbar.test.tsx +38 -0
- package/src/page-chrome/PageToolbar/PageToolbar.tsx +138 -0
- package/src/page-chrome/PageToolbar/block.meta.ts +10 -0
- package/src/page-chrome/PageToolbar/fixtures.ts +8 -0
- package/src/page-chrome/SectionHeader/SectionHeader.test.tsx +28 -0
- package/src/page-chrome/SectionHeader/SectionHeader.tsx +73 -0
- package/src/page-chrome/SectionHeader/block.meta.ts +9 -0
- package/src/page-chrome/StickyActionBar/StickyActionBar.test.tsx +29 -0
- package/src/page-chrome/StickyActionBar/StickyActionBar.tsx +66 -0
- package/src/page-chrome/StickyActionBar/block.meta.ts +9 -0
- package/src/page-chrome/index.ts +13 -0
- package/src/page-chrome/types.ts +25 -0
- package/src/scheduling/AgendaList/AgendaList.test.tsx +28 -0
- package/src/scheduling/AgendaList/AgendaList.tsx +165 -0
- package/src/scheduling/AgendaList/block.meta.ts +10 -0
- package/src/scheduling/MonthCalendar/MonthCalendar.test.tsx +32 -0
- package/src/scheduling/MonthCalendar/MonthCalendar.tsx +223 -0
- package/src/scheduling/MonthCalendar/block.meta.ts +10 -0
- package/src/scheduling/TimeSlotPicker/TimeSlotPicker.test.tsx +26 -0
- package/src/scheduling/TimeSlotPicker/TimeSlotPicker.tsx +115 -0
- package/src/scheduling/TimeSlotPicker/block.meta.ts +10 -0
- package/src/scheduling/TimeSlotPicker/fixtures.ts +10 -0
- package/src/scheduling/WeekCalendar/WeekCalendar.test.tsx +27 -0
- package/src/scheduling/WeekCalendar/WeekCalendar.tsx +274 -0
- package/src/scheduling/WeekCalendar/block.meta.ts +10 -0
- package/src/scheduling/index.ts +11 -0
- package/src/scheduling/shared/CalendarHeader.tsx +54 -0
- package/src/scheduling/shared/EventTile.tsx +21 -0
- package/src/scheduling/shared/dates.ts +98 -0
- package/src/scheduling/shared/events.ts +90 -0
- package/src/scheduling/shared/fixtures.ts +54 -0
- package/src/shell/AppSidebar/AppSidebar.test.tsx +38 -0
- package/src/shell/AppSidebar/AppSidebar.tsx +226 -0
- package/src/shell/AppSidebar/block.meta.ts +10 -0
- package/src/shell/AppSidebar/fixtures.ts +58 -0
- package/src/shell/AppTopbar/AppTopbar.test.tsx +41 -0
- package/src/shell/AppTopbar/AppTopbar.tsx +82 -0
- package/src/shell/AppTopbar/block.meta.ts +19 -0
- package/src/shell/AppTopbar/fixtures.ts +22 -0
- package/src/shell/EnvironmentBadge/EnvironmentBadge.test.tsx +22 -0
- package/src/shell/EnvironmentBadge/EnvironmentBadge.tsx +55 -0
- package/src/shell/EnvironmentBadge/block.meta.ts +10 -0
- package/src/shell/GlobalSearch/GlobalSearch.test.tsx +28 -0
- package/src/shell/GlobalSearch/GlobalSearch.tsx +80 -0
- package/src/shell/GlobalSearch/block.meta.ts +10 -0
- package/src/shell/GlobalSearch/fixtures.ts +64 -0
- package/src/shell/index.ts +11 -0
- package/src/styles.css +2 -0
- package/src/tables/DataTable/DataTable.edit-views.test.tsx +249 -0
- package/src/tables/DataTable/DataTable.layout.test.tsx +188 -0
- package/src/tables/DataTable/DataTable.single-select.test.tsx +501 -0
- package/src/tables/DataTable/DataTable.test.tsx +268 -0
- package/src/tables/DataTable/DataTable.tsx +520 -0
- package/src/tables/DataTable/block.meta.ts +27 -0
- package/src/tables/DataTable/column-menu.tsx +109 -0
- package/src/tables/DataTable/column-sizing.ts +166 -0
- package/src/tables/DataTable/data-table-body.tsx +194 -0
- package/src/tables/DataTable/data-table-props.ts +156 -0
- package/src/tables/DataTable/data-table-row.tsx +220 -0
- package/src/tables/DataTable/data-table-utils.ts +195 -0
- package/src/tables/DataTable/density-toggle.tsx +30 -0
- package/src/tables/DataTable/editable-cell.tsx +274 -0
- package/src/tables/DataTable/examples/editable.tsx +71 -0
- package/src/tables/DataTable/examples/grouped.tsx +18 -0
- package/src/tables/DataTable/examples/resizable-pinned.tsx +20 -0
- package/src/tables/DataTable/examples/saved-views.tsx +61 -0
- package/src/tables/DataTable/examples/single-selection.tsx +55 -0
- package/src/tables/DataTable/examples/virtualized.tsx +20 -0
- package/src/tables/DataTable/fixtures.ts +119 -0
- package/src/tables/DataTable/header-cell.tsx +86 -0
- package/src/tables/DataTable/resize-handle.tsx +88 -0
- package/src/tables/DataTable/single-selection.tsx +149 -0
- package/src/tables/DataTable/use-table-views.ts +79 -0
- package/src/tables/DataTable/use-virtual-rows.ts +83 -0
- package/src/tables/DataTable/views.tsx +186 -0
- package/src/tables/FilterBar/FilterBar.test.tsx +43 -0
- package/src/tables/FilterBar/FilterBar.tsx +199 -0
- package/src/tables/FilterBar/block.meta.ts +10 -0
- package/src/tables/FilterBar/fixtures.ts +32 -0
- package/src/tables/InlineEditRow/InlineEditRow.test.tsx +41 -0
- package/src/tables/InlineEditRow/InlineEditRow.tsx +215 -0
- package/src/tables/InlineEditRow/block.meta.ts +10 -0
- package/src/tables/InlineEditRow/fixtures.ts +28 -0
- package/src/tables/PaginationFooter/PaginationFooter.test.tsx +29 -0
- package/src/tables/PaginationFooter/PaginationFooter.tsx +94 -0
- package/src/tables/PaginationFooter/block.meta.ts +10 -0
- package/src/tables/SubordinateList/SubordinateList.test.tsx +351 -0
- package/src/tables/SubordinateList/SubordinateList.tsx +140 -0
- package/src/tables/SubordinateList/block.meta.ts +10 -0
- package/src/tables/SubordinateList/examples/ResourceForm.tsx +129 -0
- package/src/tables/SubordinateList/examples/empty.tsx +5 -0
- package/src/tables/SubordinateList/examples/error.tsx +5 -0
- package/src/tables/SubordinateList/examples/loading.tsx +5 -0
- package/src/tables/TruncatedCollectionFooter/TruncatedCollectionFooter.test.tsx +159 -0
- package/src/tables/TruncatedCollectionFooter/TruncatedCollectionFooter.tsx +60 -0
- package/src/tables/TruncatedCollectionFooter/block.meta.ts +10 -0
- package/src/tables/TruncatedCollectionFooter/examples/exact.tsx +6 -0
- package/src/tables/TruncatedCollectionFooter/examples/has-more.tsx +12 -0
- package/src/tables/TruncatedCollectionFooter/fixtures.ts +2 -0
- package/src/tables/index.ts +45 -0
- package/src/team/MembersTable/MembersTable.test.tsx +29 -0
- package/src/team/MembersTable/MembersTable.tsx +141 -0
- package/src/team/MembersTable/block.meta.ts +9 -0
- package/src/team/MembersTable/fixtures.ts +19 -0
- package/src/team/NotificationMatrix/NotificationMatrix.test.tsx +36 -0
- package/src/team/NotificationMatrix/NotificationMatrix.tsx +144 -0
- package/src/team/NotificationMatrix/block.meta.ts +9 -0
- package/src/team/NotificationMatrix/fixtures.ts +43 -0
- package/src/team/PendingInvitations/PendingInvitations.test.tsx +30 -0
- package/src/team/PendingInvitations/PendingInvitations.tsx +132 -0
- package/src/team/PendingInvitations/block.meta.ts +9 -0
- package/src/team/PendingInvitations/fixtures.ts +39 -0
- package/src/team/ProfileHeader/ProfileHeader.test.tsx +29 -0
- package/src/team/ProfileHeader/ProfileHeader.tsx +106 -0
- package/src/team/ProfileHeader/block.meta.ts +10 -0
- package/src/team/ProfileHeader/fixtures.ts +28 -0
- package/src/team/SessionsDevices/SessionsDevices.test.tsx +30 -0
- package/src/team/SessionsDevices/SessionsDevices.tsx +126 -0
- package/src/team/SessionsDevices/block.meta.ts +10 -0
- package/src/team/SessionsDevices/fixtures.ts +58 -0
- package/src/team/index.ts +15 -0
- package/src/test/a11y.ts +18 -0
- package/src/test/heading-levels.test.tsx +69 -0
- package/src/test/setup.ts +36 -0
- package/README.md +0 -3
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { cn, Input } from '@gntik-ai/ui';
|
|
2
|
+
import {
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useId,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type FocusEvent,
|
|
9
|
+
type KeyboardEvent,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import type { DataTableColumn } from './data-table-utils';
|
|
13
|
+
|
|
14
|
+
/** One committed cell edit, as `onCellEdit` receives it. */
|
|
15
|
+
export interface DataTableCellEdit<T> {
|
|
16
|
+
row: T;
|
|
17
|
+
rowId: string;
|
|
18
|
+
columnId: string;
|
|
19
|
+
/** Parsed value: a string (text, select) or a number / null (number editor). */
|
|
20
|
+
value: string | number | null;
|
|
21
|
+
/** Value the editor started from. */
|
|
22
|
+
previous: string | number | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Result of `onCellEdit`: nothing or `true` accepts the edit (the parent updates `rows`); a string
|
|
27
|
+
* rejects it and is shown inline as the error; `false` rejects with a generic message. A thrown
|
|
28
|
+
* error (or a rejected promise) rejects with its message.
|
|
29
|
+
*/
|
|
30
|
+
export type DataTableCellEditResult = void | boolean | string;
|
|
31
|
+
|
|
32
|
+
export type DataTableCellEditHandler<T> = (
|
|
33
|
+
edit: DataTableCellEdit<T>,
|
|
34
|
+
) => DataTableCellEditResult | Promise<DataTableCellEditResult>;
|
|
35
|
+
|
|
36
|
+
export interface EditableCellProps<T> {
|
|
37
|
+
row: T;
|
|
38
|
+
rowId: string;
|
|
39
|
+
rowLabel: string;
|
|
40
|
+
column: DataTableColumn<T>;
|
|
41
|
+
onCellEdit: DataTableCellEditHandler<T>;
|
|
42
|
+
/** Id of the shared "Press Enter or F2 to edit" hint. */
|
|
43
|
+
hintId: string;
|
|
44
|
+
/** The cell's display content. */
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const GENERIC_ERROR = 'The change could not be saved.';
|
|
49
|
+
type Move = 'self' | 'next' | 'prev' | null;
|
|
50
|
+
|
|
51
|
+
/** Starting value of the editor for a row. */
|
|
52
|
+
function startValue<T>(row: T, column: DataTableColumn<T>): string | number | null {
|
|
53
|
+
const raw = column.editValue ? column.editValue(row) : column.accessor?.(row);
|
|
54
|
+
if (raw == null) return null;
|
|
55
|
+
if (typeof raw === 'number' || typeof raw === 'string') return raw;
|
|
56
|
+
if (raw instanceof Date) return raw.toISOString();
|
|
57
|
+
return String(raw);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Focuses the next or previous editable cell of the table (Tab / Shift+Tab while editing). */
|
|
61
|
+
function focusSibling(from: HTMLElement | null, dir: 'next' | 'prev') {
|
|
62
|
+
const table = from?.closest('table');
|
|
63
|
+
if (!table || !from) return;
|
|
64
|
+
const all = [...table.querySelectorAll<HTMLElement>('[data-cell-edit-trigger]')];
|
|
65
|
+
const i = all.indexOf(from);
|
|
66
|
+
const target = all[dir === 'next' ? i + 1 : i - 1];
|
|
67
|
+
(target ?? from).focus();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* An editable body cell's content. At rest it is a button showing the value (Enter, F2 or a click
|
|
72
|
+
* edits); while editing, an input or a select: Enter or Tab commits, Escape cancels. `onCellEdit`
|
|
73
|
+
* can reject the value with a message, shown inline under the editor.
|
|
74
|
+
*/
|
|
75
|
+
export function EditableCell<T>({ row, rowId, rowLabel, column, onCellEdit, hintId, children }: EditableCellProps<T>) {
|
|
76
|
+
const errorId = useId();
|
|
77
|
+
const editor = column.editor ?? { type: 'text' as const };
|
|
78
|
+
const [editing, setEditing] = useState(false);
|
|
79
|
+
const [draft, setDraft] = useState('');
|
|
80
|
+
const [error, setError] = useState<string | null>(null);
|
|
81
|
+
const [pending, setPending] = useState(false);
|
|
82
|
+
const trigger = useRef<HTMLButtonElement>(null);
|
|
83
|
+
const field = useRef<HTMLInputElement | HTMLSelectElement | null>(null);
|
|
84
|
+
const move = useRef<Move>(null);
|
|
85
|
+
const busy = useRef(false);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (editing || !move.current) return;
|
|
89
|
+
const dir = move.current;
|
|
90
|
+
move.current = null;
|
|
91
|
+
if (dir === 'self') trigger.current?.focus();
|
|
92
|
+
else focusSibling(trigger.current, dir);
|
|
93
|
+
}, [editing]);
|
|
94
|
+
|
|
95
|
+
const focusOnMount = useCallback((el: HTMLInputElement | HTMLSelectElement | null) => {
|
|
96
|
+
field.current = el;
|
|
97
|
+
if (!el) return;
|
|
98
|
+
el.focus();
|
|
99
|
+
if (el instanceof HTMLInputElement) el.select();
|
|
100
|
+
}, []);
|
|
101
|
+
|
|
102
|
+
const start = () => {
|
|
103
|
+
const v = startValue(row, column);
|
|
104
|
+
setDraft(v == null ? '' : String(v));
|
|
105
|
+
setError(null);
|
|
106
|
+
setEditing(true);
|
|
107
|
+
};
|
|
108
|
+
const cancel = () => {
|
|
109
|
+
move.current = 'self';
|
|
110
|
+
setError(null);
|
|
111
|
+
setEditing(false);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const parse = (): { ok: true; value: string | number | null } | { ok: false; message: string } => {
|
|
115
|
+
if (editor.type !== 'number') return { ok: true, value: draft };
|
|
116
|
+
const text = draft.trim();
|
|
117
|
+
if (text === '') return { ok: true, value: null };
|
|
118
|
+
const n = Number(text);
|
|
119
|
+
if (!Number.isFinite(n)) return { ok: false, message: 'Enter a number.' };
|
|
120
|
+
if (editor.min != null && n < editor.min) return { ok: false, message: `Enter ${editor.min} or more.` };
|
|
121
|
+
if (editor.max != null && n > editor.max) return { ok: false, message: `Enter ${editor.max} or less.` };
|
|
122
|
+
return { ok: true, value: n };
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const commit = async (after: Move) => {
|
|
126
|
+
if (busy.current) return;
|
|
127
|
+
const parsed = parse();
|
|
128
|
+
if (!parsed.ok) {
|
|
129
|
+
setError(parsed.message);
|
|
130
|
+
field.current?.focus();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const previous = startValue(row, column);
|
|
134
|
+
if (
|
|
135
|
+
parsed.value === previous ||
|
|
136
|
+
(previous != null && String(previous) === String(parsed.value) && editor.type !== 'number')
|
|
137
|
+
) {
|
|
138
|
+
move.current = after;
|
|
139
|
+
setError(null);
|
|
140
|
+
setEditing(false);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
busy.current = true;
|
|
144
|
+
setPending(true);
|
|
145
|
+
let result: DataTableCellEditResult;
|
|
146
|
+
try {
|
|
147
|
+
result = await onCellEdit({ row, rowId, columnId: column.id, value: parsed.value, previous });
|
|
148
|
+
} catch (err) {
|
|
149
|
+
result = err instanceof Error && err.message ? err.message : GENERIC_ERROR;
|
|
150
|
+
}
|
|
151
|
+
busy.current = false;
|
|
152
|
+
setPending(false);
|
|
153
|
+
if (result === false) result = GENERIC_ERROR;
|
|
154
|
+
if (typeof result === 'string') {
|
|
155
|
+
setError(result);
|
|
156
|
+
if (after) field.current?.focus();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
move.current = after;
|
|
160
|
+
setError(null);
|
|
161
|
+
setEditing(false);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const onEditorKeyDown = (e: KeyboardEvent<HTMLInputElement | HTMLSelectElement>) => {
|
|
165
|
+
if (e.key === 'Escape') {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
e.stopPropagation();
|
|
168
|
+
cancel();
|
|
169
|
+
} else if (e.key === 'Enter') {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
void commit('self');
|
|
172
|
+
} else if (e.key === 'Tab') {
|
|
173
|
+
e.preventDefault();
|
|
174
|
+
void commit(e.shiftKey ? 'prev' : 'next');
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const onEditorBlur = (e: FocusEvent<HTMLInputElement | HTMLSelectElement>) => {
|
|
178
|
+
// Focus left the editor (a click elsewhere): commit in place, without moving focus.
|
|
179
|
+
if (!editing || busy.current || e.currentTarget.contains(e.relatedTarget as Node | null)) return;
|
|
180
|
+
void commit(null);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
if (!editing) {
|
|
184
|
+
return (
|
|
185
|
+
<button
|
|
186
|
+
ref={trigger}
|
|
187
|
+
type="button"
|
|
188
|
+
data-cell-edit-trigger=""
|
|
189
|
+
aria-describedby={hintId}
|
|
190
|
+
onClick={start}
|
|
191
|
+
onKeyDown={(e) => {
|
|
192
|
+
if (e.key === 'F2') {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
start();
|
|
195
|
+
}
|
|
196
|
+
}}
|
|
197
|
+
className={cn(
|
|
198
|
+
'-mx-1.5 -my-1 block max-w-[calc(100%+0.75rem)] min-w-[calc(100%+0.75rem)] cursor-text truncate rounded-sm px-1.5 py-1 text-inherit',
|
|
199
|
+
'hover:bg-secondary/60 focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-ring',
|
|
200
|
+
column.align === 'right' || column.variant === 'numeric' ? 'text-end' : 'text-start',
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
{children}
|
|
204
|
+
</button>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const label = `${column.header} for ${rowLabel}`;
|
|
209
|
+
const common = {
|
|
210
|
+
'aria-label': label,
|
|
211
|
+
'aria-invalid': error ? true : undefined,
|
|
212
|
+
'aria-describedby': error ? errorId : undefined,
|
|
213
|
+
'aria-busy': pending || undefined,
|
|
214
|
+
// Not `disabled`: the field keeps focus while an async onCellEdit runs.
|
|
215
|
+
'aria-disabled': pending || undefined,
|
|
216
|
+
onKeyDown: onEditorKeyDown,
|
|
217
|
+
onBlur: onEditorBlur,
|
|
218
|
+
};
|
|
219
|
+
return (
|
|
220
|
+
<div className="-my-1 min-w-0" data-cell-editor="">
|
|
221
|
+
{editor.type === 'select' ? (
|
|
222
|
+
<select
|
|
223
|
+
ref={focusOnMount}
|
|
224
|
+
value={draft}
|
|
225
|
+
onChange={(e) => {
|
|
226
|
+
if (!pending) setDraft(e.target.value);
|
|
227
|
+
}}
|
|
228
|
+
className={cn(
|
|
229
|
+
'h-8 w-full rounded-md border border-input bg-background px-2 text-[13px] text-foreground',
|
|
230
|
+
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring',
|
|
231
|
+
error && 'border-destructive',
|
|
232
|
+
)}
|
|
233
|
+
{...common}
|
|
234
|
+
>
|
|
235
|
+
{editor.options.map((o) => (
|
|
236
|
+
<option key={o.value} value={o.value}>
|
|
237
|
+
{o.label}
|
|
238
|
+
</option>
|
|
239
|
+
))}
|
|
240
|
+
</select>
|
|
241
|
+
) : (
|
|
242
|
+
<Input
|
|
243
|
+
ref={focusOnMount}
|
|
244
|
+
type={editor.type === 'number' ? 'number' : 'text'}
|
|
245
|
+
inputMode={editor.type === 'number' ? 'decimal' : undefined}
|
|
246
|
+
min={editor.type === 'number' ? editor.min : undefined}
|
|
247
|
+
max={editor.type === 'number' ? editor.max : undefined}
|
|
248
|
+
step={editor.type === 'number' ? editor.step : undefined}
|
|
249
|
+
placeholder={editor.type === 'text' ? editor.placeholder : undefined}
|
|
250
|
+
value={draft}
|
|
251
|
+
readOnly={pending}
|
|
252
|
+
onChange={(e) => setDraft(e.target.value)}
|
|
253
|
+
invalid={error != null}
|
|
254
|
+
className="w-full"
|
|
255
|
+
{...common}
|
|
256
|
+
/>
|
|
257
|
+
)}
|
|
258
|
+
{error && (
|
|
259
|
+
<p
|
|
260
|
+
id={errorId}
|
|
261
|
+
role="alert"
|
|
262
|
+
className="mt-1 text-start text-[11.5px] font-medium whitespace-normal text-destructive-text"
|
|
263
|
+
>
|
|
264
|
+
{error}
|
|
265
|
+
</p>
|
|
266
|
+
)}
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Whether a column is editable for a row. */
|
|
272
|
+
export function isCellEditable<T>(column: DataTableColumn<T>, row: T): boolean {
|
|
273
|
+
return typeof column.editable === 'function' ? column.editable(row) : column.editable === true;
|
|
274
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { StatusTag } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { DataTable } from '../DataTable';
|
|
4
|
+
import type { DataTableColumn } from '../data-table-utils';
|
|
5
|
+
import { DEPLOYMENT_ROWS, type DeploymentRow } from '../fixtures';
|
|
6
|
+
|
|
7
|
+
const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
|
|
8
|
+
const STATUS_OPTIONS = ['running', 'queued', 'paused', 'degraded', 'failed'].map((s) => ({
|
|
9
|
+
value: s,
|
|
10
|
+
label: s[0]!.toUpperCase() + s.slice(1),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const COLUMNS: Array<DataTableColumn<DeploymentRow>> = [
|
|
14
|
+
{
|
|
15
|
+
id: 'name',
|
|
16
|
+
header: 'Deployment',
|
|
17
|
+
accessor: (r) => r.name,
|
|
18
|
+
sortable: true,
|
|
19
|
+
hideable: false,
|
|
20
|
+
className: 'font-semibold',
|
|
21
|
+
editable: true,
|
|
22
|
+
},
|
|
23
|
+
{ id: 'region', header: 'Region', accessor: (r) => r.region, variant: 'mono' },
|
|
24
|
+
{
|
|
25
|
+
id: 'status',
|
|
26
|
+
header: 'Status',
|
|
27
|
+
accessor: (r) => r.status,
|
|
28
|
+
cell: (r) => <StatusTag status={r.status} />,
|
|
29
|
+
editable: true,
|
|
30
|
+
editor: { type: 'select', options: STATUS_OPTIONS },
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'cost',
|
|
34
|
+
header: 'Budget',
|
|
35
|
+
accessor: (r) => r.cost,
|
|
36
|
+
cell: (r) => money.format(r.cost),
|
|
37
|
+
variant: 'numeric',
|
|
38
|
+
editable: true,
|
|
39
|
+
editor: { type: 'number', min: 0, step: 0.01 },
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Inline editing: Enter or F2 edits a cell, Enter or Tab saves, Escape cancels. Names must be
|
|
45
|
+
* unique and budgets above $1,000 are rejected by the (simulated) server, with the error inline.
|
|
46
|
+
*/
|
|
47
|
+
export default function EditableDataTable() {
|
|
48
|
+
const [rows, setRows] = useState(() => DEPLOYMENT_ROWS.slice(0, 8));
|
|
49
|
+
return (
|
|
50
|
+
<DataTable<DeploymentRow>
|
|
51
|
+
caption="Deployment settings"
|
|
52
|
+
rows={rows}
|
|
53
|
+
columns={COLUMNS}
|
|
54
|
+
paginated={false}
|
|
55
|
+
selectable={false}
|
|
56
|
+
onCellEdit={async ({ rowId, columnId, value }) => {
|
|
57
|
+
if (columnId === 'name') {
|
|
58
|
+
const name = String(value ?? '').trim();
|
|
59
|
+
if (!name) return 'Enter a name.';
|
|
60
|
+
if (rows.some((r) => r.id !== rowId && r.name === name)) return `“${name}” is already taken.`;
|
|
61
|
+
}
|
|
62
|
+
if (columnId === 'cost') {
|
|
63
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
64
|
+
if (typeof value !== 'number') return 'Enter a budget.';
|
|
65
|
+
if (value > 1000) return 'Budgets above $1,000 need approval.';
|
|
66
|
+
}
|
|
67
|
+
setRows((prev) => prev.map((r) => (r.id === rowId ? { ...r, [columnId]: value } : r)));
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataTable } from '../DataTable';
|
|
2
|
+
import { DEPLOYMENT_COLUMNS, DEPLOYMENT_ROWS, type DeploymentRow } from '../fixtures';
|
|
3
|
+
|
|
4
|
+
/** Deployments grouped by region: collapsible group headers with a row count, sorting inside groups. */
|
|
5
|
+
export default function GroupedDataTable() {
|
|
6
|
+
return (
|
|
7
|
+
<DataTable<DeploymentRow>
|
|
8
|
+
caption="Deployments by region"
|
|
9
|
+
rows={DEPLOYMENT_ROWS}
|
|
10
|
+
columns={DEPLOYMENT_COLUMNS}
|
|
11
|
+
groupBy="region"
|
|
12
|
+
groupLabel={(region) => <span className="font-mono">{region}</span>}
|
|
13
|
+
defaultCollapsedGroups={['ap-south-1']}
|
|
14
|
+
paginated={false}
|
|
15
|
+
defaultSort={{ columnId: 'cost', direction: 'descending' }}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataTable } from '../DataTable';
|
|
2
|
+
import { DEPLOYMENT_COLUMNS, DEPLOYMENT_ROWS, type DeploymentRow } from '../fixtures';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resizable columns (drag a header edge, or focus it and use the arrow keys) with the name pinned
|
|
6
|
+
* to the start and the cost pinned to the end: they stay in view while the table scrolls sideways.
|
|
7
|
+
*/
|
|
8
|
+
export default function ResizablePinnedDataTable() {
|
|
9
|
+
return (
|
|
10
|
+
<DataTable<DeploymentRow>
|
|
11
|
+
caption="Deployments"
|
|
12
|
+
rows={DEPLOYMENT_ROWS}
|
|
13
|
+
columns={DEPLOYMENT_COLUMNS}
|
|
14
|
+
resizable
|
|
15
|
+
defaultColumnWidths={{ name: 220, region: 180, status: 160, requests: 160, cost: 140, updated: 160 }}
|
|
16
|
+
defaultPinnedColumns={{ left: ['name'], right: ['cost'] }}
|
|
17
|
+
rowActions={() => [{ label: 'Open' }, { label: 'Redeploy' }]}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { SimpleSelect } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { DataTable } from '../DataTable';
|
|
4
|
+
import { DEPLOYMENT_COLUMNS, DEPLOYMENT_ROWS, type DeploymentRow } from '../fixtures';
|
|
5
|
+
import type { DataTableView } from '../views';
|
|
6
|
+
|
|
7
|
+
interface Filters {
|
|
8
|
+
status: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const VIEWS: DataTableView[] = [
|
|
12
|
+
{
|
|
13
|
+
id: 'expensive',
|
|
14
|
+
name: 'Most expensive',
|
|
15
|
+
state: { sort: { columnId: 'cost', direction: 'descending' }, hiddenColumns: ['region', 'updated'] },
|
|
16
|
+
},
|
|
17
|
+
{ id: 'by-region', name: 'By region', state: { groupBy: 'region', pinnedColumns: { left: ['name'] } } },
|
|
18
|
+
{
|
|
19
|
+
id: 'failing',
|
|
20
|
+
name: 'Needs attention',
|
|
21
|
+
state: { filters: { status: 'failed' }, sort: { columnId: 'updated', direction: 'descending' }, hiddenColumns: [] },
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const STATUS_FILTER = [
|
|
26
|
+
{ value: 'all', label: 'All statuses' },
|
|
27
|
+
{ value: 'running', label: 'Running' },
|
|
28
|
+
{ value: 'failed', label: 'Failed' },
|
|
29
|
+
{ value: 'degraded', label: 'Degraded' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Saved views: switch between views, change the table (sort, columns, widths, pinning,
|
|
34
|
+
* grouping, the status filter) and save the result as a new view, rename, delete or reset it.
|
|
35
|
+
*/
|
|
36
|
+
export default function SavedViewsDataTable() {
|
|
37
|
+
const [views, setViews] = useState<DataTableView[]>(VIEWS);
|
|
38
|
+
const [filters, setFilters] = useState<Filters>({ status: 'all' });
|
|
39
|
+
const rows = filters.status === 'all' ? DEPLOYMENT_ROWS : DEPLOYMENT_ROWS.filter((r) => r.status === filters.status);
|
|
40
|
+
return (
|
|
41
|
+
<DataTable<DeploymentRow>
|
|
42
|
+
caption="Deployments"
|
|
43
|
+
rows={rows}
|
|
44
|
+
columns={DEPLOYMENT_COLUMNS}
|
|
45
|
+
resizable
|
|
46
|
+
views={views}
|
|
47
|
+
onViewsChange={setViews}
|
|
48
|
+
filters={filters}
|
|
49
|
+
onFiltersChange={(f) => setFilters((f as Filters | undefined) ?? { status: 'all' })}
|
|
50
|
+
toolbar={
|
|
51
|
+
<SimpleSelect
|
|
52
|
+
aria-label="Status"
|
|
53
|
+
size="sm"
|
|
54
|
+
value={filters.status}
|
|
55
|
+
onValueChange={(status) => setFilters({ status: status ?? 'all' })}
|
|
56
|
+
items={STATUS_FILTER}
|
|
57
|
+
/>
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { DataTable } from '../DataTable';
|
|
3
|
+
|
|
4
|
+
const items = [
|
|
5
|
+
{ id: 'item-a', name: 'Item A' },
|
|
6
|
+
{ id: 'item-b', name: 'Item B' },
|
|
7
|
+
{ id: 'item-c', name: 'Item C' },
|
|
8
|
+
];
|
|
9
|
+
const itemColumns = [{ id: 'name', header: 'Name', accessor: (row: (typeof items)[number]) => row.name }];
|
|
10
|
+
const versions = [
|
|
11
|
+
{ id: 'v3', name: 'Version 3', eligible: true },
|
|
12
|
+
{ id: 'v2', name: 'Version 2', eligible: false },
|
|
13
|
+
{ id: 'v1', name: 'Version 1', eligible: true },
|
|
14
|
+
];
|
|
15
|
+
const versionColumns = [
|
|
16
|
+
{ id: 'name', header: 'Version', accessor: (row: (typeof versions)[number]) => row.name, sortable: true },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** Supplied selectionName values must be unique per page; omitted names are instance-unique. */
|
|
20
|
+
export default function SingleSelectionExample() {
|
|
21
|
+
const [selectedId, setSelectedId] = useState<string | null>('v2');
|
|
22
|
+
return (
|
|
23
|
+
<div className="space-y-4">
|
|
24
|
+
<DataTable
|
|
25
|
+
rows={items}
|
|
26
|
+
columns={itemColumns}
|
|
27
|
+
caption="Items"
|
|
28
|
+
selectionMode="single"
|
|
29
|
+
paginated={false}
|
|
30
|
+
legend="Available items"
|
|
31
|
+
selectionName="example-item-choice"
|
|
32
|
+
defaultSelectedId="item-a"
|
|
33
|
+
showColumnMenu={false}
|
|
34
|
+
showDensityToggle={false}
|
|
35
|
+
/>
|
|
36
|
+
<DataTable
|
|
37
|
+
rows={versions}
|
|
38
|
+
columns={versionColumns}
|
|
39
|
+
caption="Versions"
|
|
40
|
+
selectionMode="single"
|
|
41
|
+
legend="Available versions"
|
|
42
|
+
selectionName="example-version-choice"
|
|
43
|
+
getRowLabel={(row) => row.name}
|
|
44
|
+
selectedId={selectedId}
|
|
45
|
+
onSelectedIdChange={setSelectedId}
|
|
46
|
+
isRowDisabled={(row) => !row.eligible}
|
|
47
|
+
resizable
|
|
48
|
+
groupBy={() => 'Version history'}
|
|
49
|
+
collapsibleGroups
|
|
50
|
+
showColumnMenu={false}
|
|
51
|
+
showDensityToggle={false}
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataTable } from '../DataTable';
|
|
2
|
+
import { DEPLOYMENT_COLUMNS, generateDeployments, type DeploymentRow } from '../fixtures';
|
|
3
|
+
|
|
4
|
+
const ROWS = generateDeployments(5_000);
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 5,000 rows without pagination: only the rows in view are rendered (aria-rowcount and
|
|
8
|
+
* aria-rowindex keep the full count). Select-all still covers every row.
|
|
9
|
+
*/
|
|
10
|
+
export default function VirtualizedDataTable() {
|
|
11
|
+
return (
|
|
12
|
+
<DataTable<DeploymentRow>
|
|
13
|
+
caption="All deployments"
|
|
14
|
+
rows={ROWS}
|
|
15
|
+
columns={DEPLOYMENT_COLUMNS}
|
|
16
|
+
paginated={false}
|
|
17
|
+
virtualContainerClassName="max-h-[28rem]"
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { StatusTag } from '@gntik-ai/ui';
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import type { DataTableColumn } from './data-table-utils';
|
|
4
|
+
|
|
5
|
+
export interface DeploymentRow {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
region: string;
|
|
9
|
+
status: 'running' | 'queued' | 'paused' | 'degraded' | 'failed';
|
|
10
|
+
requests: number;
|
|
11
|
+
cost: number;
|
|
12
|
+
updatedAt: Date;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const NAMES = [
|
|
16
|
+
'orders-api',
|
|
17
|
+
'billing-sync',
|
|
18
|
+
'invoice-worker',
|
|
19
|
+
'search-index',
|
|
20
|
+
'auth-gateway',
|
|
21
|
+
'media-resizer',
|
|
22
|
+
'nightly-export',
|
|
23
|
+
'webhooks',
|
|
24
|
+
'reports',
|
|
25
|
+
'notifications',
|
|
26
|
+
'checkout-web',
|
|
27
|
+
'audit-log',
|
|
28
|
+
];
|
|
29
|
+
const REGIONS = ['eu-west-1', 'us-east-1', 'ap-south-1', 'eu-central-1'];
|
|
30
|
+
const STATUSES: DeploymentRow['status'][] = [
|
|
31
|
+
'running',
|
|
32
|
+
'running',
|
|
33
|
+
'running',
|
|
34
|
+
'queued',
|
|
35
|
+
'paused',
|
|
36
|
+
'degraded',
|
|
37
|
+
'running',
|
|
38
|
+
'failed',
|
|
39
|
+
];
|
|
40
|
+
const BASE = Date.UTC(2026, 8, 30, 12, 0, 0);
|
|
41
|
+
|
|
42
|
+
const SUFFIXES = ['', '-staging', '-canary', '-preview'];
|
|
43
|
+
|
|
44
|
+
/** Deterministic deployments (the first 24 are DEPLOYMENT_ROWS); large counts exercise virtualization. */
|
|
45
|
+
export function generateDeployments(count: number): DeploymentRow[] {
|
|
46
|
+
return Array.from({ length: count }, (_, i) => {
|
|
47
|
+
const round = Math.floor(i / NAMES.length);
|
|
48
|
+
const suffix = round < SUFFIXES.length ? SUFFIXES[round] : `-${round}`;
|
|
49
|
+
return {
|
|
50
|
+
id: `dep_${(1000 + i * 37).toString(36)}`,
|
|
51
|
+
name: `${NAMES[i % NAMES.length]}${suffix}`,
|
|
52
|
+
region: REGIONS[(i * 3) % REGIONS.length] ?? 'eu-west-1',
|
|
53
|
+
status: STATUSES[(i * 5) % STATUSES.length] ?? 'running',
|
|
54
|
+
requests: ((i * 7919) % 90_000) + 1_200,
|
|
55
|
+
cost: Math.round((((i * 3571) % 900) + 40) * 100) / 100,
|
|
56
|
+
updatedAt: new Date(BASE - i * 3_700_000 * 5),
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 24 deployments: enough for two pages at the default page size. */
|
|
62
|
+
export const DEPLOYMENT_ROWS: DeploymentRow[] = generateDeployments(24);
|
|
63
|
+
|
|
64
|
+
const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' });
|
|
65
|
+
const count = new Intl.NumberFormat('en-US');
|
|
66
|
+
|
|
67
|
+
/** Columns for DEPLOYMENT_ROWS. */
|
|
68
|
+
export const DEPLOYMENT_COLUMNS: DataTableColumn<DeploymentRow>[] = [
|
|
69
|
+
{
|
|
70
|
+
id: 'name',
|
|
71
|
+
header: 'Deployment',
|
|
72
|
+
accessor: (r) => r.name,
|
|
73
|
+
sortable: true,
|
|
74
|
+
hideable: false,
|
|
75
|
+
className: 'font-semibold',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'region',
|
|
79
|
+
header: 'Region',
|
|
80
|
+
accessor: (r) => r.region,
|
|
81
|
+
sortable: true,
|
|
82
|
+
className: 'font-mono text-[12px] text-muted-foreground',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'status',
|
|
86
|
+
header: 'Status',
|
|
87
|
+
accessor: (r) => r.status,
|
|
88
|
+
cell: (r) => createElement(StatusTag, { status: r.status }),
|
|
89
|
+
sortable: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'requests',
|
|
93
|
+
header: 'Requests',
|
|
94
|
+
accessor: (r) => r.requests,
|
|
95
|
+
cell: (r) => count.format(r.requests),
|
|
96
|
+
sortable: true,
|
|
97
|
+
align: 'right',
|
|
98
|
+
className: 'font-mono text-[12.5px]',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: 'cost',
|
|
102
|
+
header: 'Cost',
|
|
103
|
+
accessor: (r) => r.cost,
|
|
104
|
+
cell: (r) => money.format(r.cost),
|
|
105
|
+
sortable: true,
|
|
106
|
+
align: 'right',
|
|
107
|
+
className: 'font-mono text-[12.5px]',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
id: 'updated',
|
|
111
|
+
header: 'Updated',
|
|
112
|
+
accessor: (r) => r.updatedAt,
|
|
113
|
+
cell: (r) => r.updatedAt.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }),
|
|
114
|
+
sortable: true,
|
|
115
|
+
align: 'right',
|
|
116
|
+
defaultHidden: true,
|
|
117
|
+
className: 'text-[12px] text-muted-foreground',
|
|
118
|
+
},
|
|
119
|
+
];
|