@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,94 @@
|
|
|
1
|
+
import { cn, Pagination, SimpleSelect, useI18n } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface PaginationFooterProps {
|
|
5
|
+
/** Total number of rows. */
|
|
6
|
+
total?: number;
|
|
7
|
+
/** Current page, 1-based (controlled). */
|
|
8
|
+
page?: number;
|
|
9
|
+
defaultPage?: number;
|
|
10
|
+
onPageChange?: (page: number) => void;
|
|
11
|
+
/** Rows per page (controlled). */
|
|
12
|
+
pageSize?: number;
|
|
13
|
+
defaultPageSize?: number;
|
|
14
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
15
|
+
pageSizeOptions?: readonly number[];
|
|
16
|
+
/** What the rows are, for the accessible names ("Deployments"). */
|
|
17
|
+
noun?: string;
|
|
18
|
+
locale?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Table footer: rows-per-page Select, a "1–10 of 97" summary and numbered Pagination. Stacks on small screens. */
|
|
23
|
+
export function PaginationFooter({
|
|
24
|
+
total = 97,
|
|
25
|
+
page: pageProp,
|
|
26
|
+
defaultPage = 1,
|
|
27
|
+
onPageChange,
|
|
28
|
+
pageSize: sizeProp,
|
|
29
|
+
defaultPageSize = 10,
|
|
30
|
+
onPageSizeChange,
|
|
31
|
+
pageSizeOptions = [10, 25, 50, 100],
|
|
32
|
+
noun: nounProp,
|
|
33
|
+
locale: localeProp,
|
|
34
|
+
className,
|
|
35
|
+
}: PaginationFooterProps) {
|
|
36
|
+
const { t, locale: providerLocale } = useI18n();
|
|
37
|
+
const locale = localeProp ?? providerLocale;
|
|
38
|
+
const noun = nounProp ?? t('table.rows');
|
|
39
|
+
const [innerPage, setInnerPage] = useState(defaultPage);
|
|
40
|
+
const [innerSize, setInnerSize] = useState(defaultPageSize);
|
|
41
|
+
const pageSize = sizeProp ?? innerSize;
|
|
42
|
+
const pageCount = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
|
|
43
|
+
const page = Math.min(Math.max(1, pageProp ?? innerPage), pageCount);
|
|
44
|
+
const from = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
45
|
+
const to = Math.min(page * pageSize, total);
|
|
46
|
+
const fmt = (n: number) => n.toLocaleString(locale);
|
|
47
|
+
|
|
48
|
+
const goTo = (next: number) => {
|
|
49
|
+
setInnerPage(next);
|
|
50
|
+
onPageChange?.(next);
|
|
51
|
+
};
|
|
52
|
+
const resize = (value: string | null) => {
|
|
53
|
+
const next = Number(value);
|
|
54
|
+
if (!next || next === pageSize) return;
|
|
55
|
+
setInnerSize(next);
|
|
56
|
+
onPageSizeChange?.(next);
|
|
57
|
+
// Keep the first visible row on screen.
|
|
58
|
+
const nextPage = Math.floor((from - 1) / next) + 1;
|
|
59
|
+
if (nextPage !== page) goTo(Math.max(1, nextPage));
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div className={cn('flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between', className)}>
|
|
64
|
+
<div className="flex items-center gap-2.5">
|
|
65
|
+
<span className="text-[12.5px] text-muted-foreground" aria-hidden>
|
|
66
|
+
{t('table.rowsPerPage')}
|
|
67
|
+
</span>
|
|
68
|
+
<SimpleSelect
|
|
69
|
+
aria-label={t('table.rowsPerPage')}
|
|
70
|
+
size="sm"
|
|
71
|
+
className="w-[76px] font-mono"
|
|
72
|
+
value={String(pageSize)}
|
|
73
|
+
onValueChange={resize}
|
|
74
|
+
items={pageSizeOptions.map((n) => ({ value: String(n), label: String(n) }))}
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
<div className="flex flex-col gap-3 sm:flex-row sm:items-center">
|
|
78
|
+
<p className="text-[12.5px] text-muted-foreground tabular-nums" aria-live="polite">
|
|
79
|
+
<span className="font-mono text-foreground">
|
|
80
|
+
{fmt(from)}–{fmt(to)}
|
|
81
|
+
</span>{' '}
|
|
82
|
+
{t('pagination.of')} <span className="font-mono text-foreground">{fmt(total)}</span>
|
|
83
|
+
</p>
|
|
84
|
+
<Pagination
|
|
85
|
+
page={page}
|
|
86
|
+
pageCount={pageCount}
|
|
87
|
+
onPageChange={goTo}
|
|
88
|
+
size="sm"
|
|
89
|
+
labels={{ nav: t('table.pagination', { noun }) }}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BlockMeta } from '../../meta';
|
|
2
|
+
|
|
3
|
+
export const meta: BlockMeta = {
|
|
4
|
+
name: 'Pagination footer',
|
|
5
|
+
family: 'tables',
|
|
6
|
+
status: 'beta',
|
|
7
|
+
description:
|
|
8
|
+
'Table footer with a rows-per-page Select, a "1–10 of 97" summary and numbered Pagination; controlled or uncontrolled.',
|
|
9
|
+
uses: ['SimpleSelect', 'Pagination'],
|
|
10
|
+
};
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { render, screen, within } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
4
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
5
|
+
import type { DataTableColumn } from '../DataTable/data-table-utils';
|
|
6
|
+
import { SubordinateList, type SubordinateListProps } from './SubordinateList';
|
|
7
|
+
import ResourceFormExample from './examples/ResourceForm';
|
|
8
|
+
|
|
9
|
+
interface Row {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
const columns: DataTableColumn<Row>[] = [{ id: 'name', header: 'Name', accessor: (row) => row.name, sortable: true }];
|
|
14
|
+
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
|
|
15
|
+
id: String(i),
|
|
16
|
+
name: `Record ${i + 1}`,
|
|
17
|
+
}));
|
|
18
|
+
const props: SubordinateListProps<Row> = {
|
|
19
|
+
title: 'History',
|
|
20
|
+
headingLevel: 'h2',
|
|
21
|
+
count: 37,
|
|
22
|
+
columns,
|
|
23
|
+
rows,
|
|
24
|
+
getRowId: (row) => row.id,
|
|
25
|
+
pagination: null,
|
|
26
|
+
loading: false,
|
|
27
|
+
error: null,
|
|
28
|
+
onRetry: () => {},
|
|
29
|
+
emptyState: <p>No history yet</p>,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// The public prop contract: every omitted input must be a type error.
|
|
33
|
+
function requiredProps(input: SubordinateListProps<Row>) {
|
|
34
|
+
const { title, headingLevel, count, columns, rows, getRowId, pagination, loading, error, onRetry, emptyState } =
|
|
35
|
+
input;
|
|
36
|
+
// @ts-expect-error title is required
|
|
37
|
+
<SubordinateList
|
|
38
|
+
headingLevel={headingLevel}
|
|
39
|
+
count={count}
|
|
40
|
+
columns={columns}
|
|
41
|
+
rows={rows}
|
|
42
|
+
getRowId={getRowId}
|
|
43
|
+
pagination={pagination}
|
|
44
|
+
loading={loading}
|
|
45
|
+
error={error}
|
|
46
|
+
onRetry={onRetry}
|
|
47
|
+
emptyState={emptyState}
|
|
48
|
+
/>;
|
|
49
|
+
// @ts-expect-error headingLevel is required
|
|
50
|
+
<SubordinateList
|
|
51
|
+
title={title}
|
|
52
|
+
count={count}
|
|
53
|
+
columns={columns}
|
|
54
|
+
rows={rows}
|
|
55
|
+
getRowId={getRowId}
|
|
56
|
+
pagination={pagination}
|
|
57
|
+
loading={loading}
|
|
58
|
+
error={error}
|
|
59
|
+
onRetry={onRetry}
|
|
60
|
+
emptyState={emptyState}
|
|
61
|
+
/>;
|
|
62
|
+
// @ts-expect-error count is required
|
|
63
|
+
<SubordinateList
|
|
64
|
+
title={title}
|
|
65
|
+
headingLevel={headingLevel}
|
|
66
|
+
columns={columns}
|
|
67
|
+
rows={rows}
|
|
68
|
+
getRowId={getRowId}
|
|
69
|
+
pagination={pagination}
|
|
70
|
+
loading={loading}
|
|
71
|
+
error={error}
|
|
72
|
+
onRetry={onRetry}
|
|
73
|
+
emptyState={emptyState}
|
|
74
|
+
/>;
|
|
75
|
+
// @ts-expect-error columns are required
|
|
76
|
+
<SubordinateList
|
|
77
|
+
title={title}
|
|
78
|
+
headingLevel={headingLevel}
|
|
79
|
+
count={count}
|
|
80
|
+
rows={rows}
|
|
81
|
+
getRowId={getRowId}
|
|
82
|
+
pagination={pagination}
|
|
83
|
+
loading={loading}
|
|
84
|
+
error={error}
|
|
85
|
+
onRetry={onRetry}
|
|
86
|
+
emptyState={emptyState}
|
|
87
|
+
/>;
|
|
88
|
+
// @ts-expect-error rows are required
|
|
89
|
+
<SubordinateList
|
|
90
|
+
title={title}
|
|
91
|
+
headingLevel={headingLevel}
|
|
92
|
+
count={count}
|
|
93
|
+
columns={columns}
|
|
94
|
+
getRowId={getRowId}
|
|
95
|
+
pagination={pagination}
|
|
96
|
+
loading={loading}
|
|
97
|
+
error={error}
|
|
98
|
+
onRetry={onRetry}
|
|
99
|
+
emptyState={emptyState}
|
|
100
|
+
/>;
|
|
101
|
+
// @ts-expect-error getRowId is required
|
|
102
|
+
<SubordinateList
|
|
103
|
+
title={title}
|
|
104
|
+
headingLevel={headingLevel}
|
|
105
|
+
count={count}
|
|
106
|
+
columns={columns}
|
|
107
|
+
rows={rows}
|
|
108
|
+
pagination={pagination}
|
|
109
|
+
loading={loading}
|
|
110
|
+
error={error}
|
|
111
|
+
onRetry={onRetry}
|
|
112
|
+
emptyState={emptyState}
|
|
113
|
+
/>;
|
|
114
|
+
// @ts-expect-error pagination is required
|
|
115
|
+
<SubordinateList
|
|
116
|
+
title={title}
|
|
117
|
+
headingLevel={headingLevel}
|
|
118
|
+
count={count}
|
|
119
|
+
columns={columns}
|
|
120
|
+
rows={rows}
|
|
121
|
+
getRowId={getRowId}
|
|
122
|
+
loading={loading}
|
|
123
|
+
error={error}
|
|
124
|
+
onRetry={onRetry}
|
|
125
|
+
emptyState={emptyState}
|
|
126
|
+
/>;
|
|
127
|
+
// @ts-expect-error loading is required
|
|
128
|
+
<SubordinateList
|
|
129
|
+
title={title}
|
|
130
|
+
headingLevel={headingLevel}
|
|
131
|
+
count={count}
|
|
132
|
+
columns={columns}
|
|
133
|
+
rows={rows}
|
|
134
|
+
getRowId={getRowId}
|
|
135
|
+
pagination={pagination}
|
|
136
|
+
error={error}
|
|
137
|
+
onRetry={onRetry}
|
|
138
|
+
emptyState={emptyState}
|
|
139
|
+
/>;
|
|
140
|
+
// @ts-expect-error error is required
|
|
141
|
+
<SubordinateList
|
|
142
|
+
title={title}
|
|
143
|
+
headingLevel={headingLevel}
|
|
144
|
+
count={count}
|
|
145
|
+
columns={columns}
|
|
146
|
+
rows={rows}
|
|
147
|
+
getRowId={getRowId}
|
|
148
|
+
pagination={pagination}
|
|
149
|
+
loading={loading}
|
|
150
|
+
onRetry={onRetry}
|
|
151
|
+
emptyState={emptyState}
|
|
152
|
+
/>;
|
|
153
|
+
// @ts-expect-error onRetry is required
|
|
154
|
+
<SubordinateList
|
|
155
|
+
title={title}
|
|
156
|
+
headingLevel={headingLevel}
|
|
157
|
+
count={count}
|
|
158
|
+
columns={columns}
|
|
159
|
+
rows={rows}
|
|
160
|
+
getRowId={getRowId}
|
|
161
|
+
pagination={pagination}
|
|
162
|
+
loading={loading}
|
|
163
|
+
error={error}
|
|
164
|
+
emptyState={emptyState}
|
|
165
|
+
/>;
|
|
166
|
+
// @ts-expect-error emptyState is required
|
|
167
|
+
<SubordinateList
|
|
168
|
+
title={title}
|
|
169
|
+
headingLevel={headingLevel}
|
|
170
|
+
count={count}
|
|
171
|
+
columns={columns}
|
|
172
|
+
rows={rows}
|
|
173
|
+
getRowId={getRowId}
|
|
174
|
+
pagination={pagination}
|
|
175
|
+
loading={loading}
|
|
176
|
+
error={error}
|
|
177
|
+
onRetry={onRetry}
|
|
178
|
+
/>;
|
|
179
|
+
}
|
|
180
|
+
void requiredProps;
|
|
181
|
+
|
|
182
|
+
describe('SubordinateList', () => {
|
|
183
|
+
it('embeds a paginated history and an unpaginated consumer section in a resource-form host', async () => {
|
|
184
|
+
render(<ResourceFormExample />);
|
|
185
|
+
expect(screen.getByRole('form', { name: 'Resource settings' })).toBeVisible();
|
|
186
|
+
const history = screen.getByRole('region', { name: 'History' });
|
|
187
|
+
const consumers = screen.getByRole('region', { name: 'Consumers' });
|
|
188
|
+
expect(within(history).getByRole('navigation', { name: 'History pagination' })).toBeVisible();
|
|
189
|
+
expect(within(consumers).queryByRole('navigation')).not.toBeInTheDocument();
|
|
190
|
+
await expectNoAxeViolations(document.body);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
for (const theme of ['dark', 'light', 'high_contrast']) {
|
|
194
|
+
it.each(['default', 'loading', 'empty', 'error'] as const)(
|
|
195
|
+
`has no axe violations in ${theme} / %s`,
|
|
196
|
+
async (state) => {
|
|
197
|
+
document.documentElement.className = theme;
|
|
198
|
+
const { container } = render(
|
|
199
|
+
<SubordinateList
|
|
200
|
+
{...props}
|
|
201
|
+
loading={state === 'loading'}
|
|
202
|
+
rows={state === 'empty' ? [] : rows}
|
|
203
|
+
error={
|
|
204
|
+
state === 'error'
|
|
205
|
+
? {
|
|
206
|
+
title: 'History unavailable',
|
|
207
|
+
message: 'Please retry.',
|
|
208
|
+
code: null,
|
|
209
|
+
}
|
|
210
|
+
: null
|
|
211
|
+
}
|
|
212
|
+
pagination={{
|
|
213
|
+
limit: 10,
|
|
214
|
+
offset: 0,
|
|
215
|
+
total: state === 'empty' ? 0 : 37,
|
|
216
|
+
onPageChange: () => {},
|
|
217
|
+
}}
|
|
218
|
+
/>,
|
|
219
|
+
);
|
|
220
|
+
await expectNoAxeViolations(container);
|
|
221
|
+
},
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
it.each(['en', 'es'])('shows only the supplied error and retries the failing section once in %s', async (locale) => {
|
|
226
|
+
const user = userEvent.setup();
|
|
227
|
+
const onRetry = vi.fn();
|
|
228
|
+
render(
|
|
229
|
+
<I18nProvider locale={locale}>
|
|
230
|
+
<SubordinateList
|
|
231
|
+
{...props}
|
|
232
|
+
error={{
|
|
233
|
+
title: 'History unavailable',
|
|
234
|
+
message: 'Please retry this section.',
|
|
235
|
+
code: null,
|
|
236
|
+
}}
|
|
237
|
+
onRetry={onRetry}
|
|
238
|
+
/>
|
|
239
|
+
<SubordinateList {...props} title="Consumers" headingLevel="h3" />
|
|
240
|
+
</I18nProvider>,
|
|
241
|
+
);
|
|
242
|
+
const failed = screen.getByRole('region', { name: 'History' });
|
|
243
|
+
expect(
|
|
244
|
+
within(failed).getByRole('heading', {
|
|
245
|
+
name: 'History unavailable',
|
|
246
|
+
level: 3,
|
|
247
|
+
}),
|
|
248
|
+
).toBeVisible();
|
|
249
|
+
expect(failed).toHaveTextContent('Please retry this section.');
|
|
250
|
+
expect(failed).not.toHaveTextContent(/503|req_|Contact support|deployments|Add policy/i);
|
|
251
|
+
expect(within(failed).queryByRole('table')).not.toBeInTheDocument();
|
|
252
|
+
expect(within(failed).queryByRole('navigation')).not.toBeInTheDocument();
|
|
253
|
+
const retryLabel = locale === 'es' ? 'Reintentar' : 'Try again';
|
|
254
|
+
await user.click(within(failed).getByRole('button', { name: retryLabel }));
|
|
255
|
+
expect(onRetry).toHaveBeenCalledTimes(1);
|
|
256
|
+
const healthy = screen.getByRole('region', { name: 'Consumers' });
|
|
257
|
+
expect(within(healthy).getByRole('table', { name: 'Consumers' })).toBeVisible();
|
|
258
|
+
expect(within(healthy).queryByRole('button', { name: retryLabel })).not.toBeInTheDocument();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('shows an explicit error code and keeps the header while a section has failed', () => {
|
|
262
|
+
render(
|
|
263
|
+
<SubordinateList
|
|
264
|
+
{...props}
|
|
265
|
+
error={{
|
|
266
|
+
title: 'History unavailable',
|
|
267
|
+
message: 'Try later.',
|
|
268
|
+
code: 'E_LOAD',
|
|
269
|
+
}}
|
|
270
|
+
/>,
|
|
271
|
+
);
|
|
272
|
+
expect(screen.getByText('E_LOAD')).toBeVisible();
|
|
273
|
+
expect(screen.getByRole('heading', { name: 'History', level: 2 })).toBeVisible();
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('replaces the table and pagination with a busy TableSkeleton while loading', () => {
|
|
277
|
+
render(
|
|
278
|
+
<SubordinateList
|
|
279
|
+
{...props}
|
|
280
|
+
loading={true}
|
|
281
|
+
pagination={{ limit: 10, offset: 0, total: 37, onPageChange: () => {} }}
|
|
282
|
+
/>,
|
|
283
|
+
);
|
|
284
|
+
expect(screen.getByRole('region', { name: 'History' })).toHaveAttribute('aria-busy', 'true');
|
|
285
|
+
expect(screen.getByRole('status')).toHaveTextContent('Loading table');
|
|
286
|
+
expect(screen.queryByRole('table')).not.toBeInTheDocument();
|
|
287
|
+
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('renders the host empty state instead of a table when rows are empty', () => {
|
|
291
|
+
render(<SubordinateList {...props} rows={[]} count={0} />);
|
|
292
|
+
expect(screen.getByText('No history yet')).toBeVisible();
|
|
293
|
+
expect(screen.queryByRole('table')).not.toBeInTheDocument();
|
|
294
|
+
expect(screen.getByRole('region', { name: 'History' })).toHaveAttribute('aria-busy', 'false');
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it('renders every supplied row with server pagination and translates page 2 to offset 10', async () => {
|
|
298
|
+
const user = userEvent.setup();
|
|
299
|
+
const onPageChange = vi.fn();
|
|
300
|
+
const { rerender } = render(
|
|
301
|
+
<SubordinateList {...props} pagination={{ limit: 10, offset: 0, total: 37, onPageChange }} />,
|
|
302
|
+
);
|
|
303
|
+
expect(screen.getAllByRole('row')).toHaveLength(13);
|
|
304
|
+
expect(screen.getByRole('region', { name: 'History' })).toHaveTextContent('1–10 of 37');
|
|
305
|
+
expect(screen.getByRole('navigation', { name: 'History pagination' })).toBeVisible();
|
|
306
|
+
await user.click(screen.getByRole('button', { name: 'Page 2' }));
|
|
307
|
+
expect(onPageChange).toHaveBeenCalledExactlyOnceWith(10);
|
|
308
|
+
// Controlled: only a new host offset changes the page summary.
|
|
309
|
+
expect(screen.getByText('1–10')).toBeVisible();
|
|
310
|
+
rerender(<SubordinateList {...props} pagination={{ limit: 10, offset: 10, total: 37, onPageChange }} />);
|
|
311
|
+
expect(screen.getByText('11–20')).toBeVisible();
|
|
312
|
+
await user.click(screen.getByRole('combobox', { name: 'Rows per page' }));
|
|
313
|
+
expect(await screen.findAllByRole('option')).toHaveLength(1);
|
|
314
|
+
expect(screen.getByRole('option', { name: '10' })).toBeVisible();
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
it('renders a large unpaginated collection without list controls, sorting, virtualization or sticky elements', () => {
|
|
318
|
+
const largeRows = Array.from({ length: 120 }, (_, i) => ({
|
|
319
|
+
id: String(i),
|
|
320
|
+
name: `Entry ${i}`,
|
|
321
|
+
}));
|
|
322
|
+
const { container } = render(<SubordinateList {...props} rows={largeRows} count={120} />);
|
|
323
|
+
expect(screen.getAllByRole('row')).toHaveLength(121);
|
|
324
|
+
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
|
|
325
|
+
expect(screen.queryByRole('checkbox')).not.toBeInTheDocument();
|
|
326
|
+
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
|
327
|
+
expect(screen.queryByRole('toolbar')).not.toBeInTheDocument();
|
|
328
|
+
expect(screen.queryByRole('searchbox')).not.toBeInTheDocument();
|
|
329
|
+
expect(screen.getByRole('table', { name: 'History' })).not.toHaveAttribute('data-virtualized');
|
|
330
|
+
for (const element of container.querySelectorAll<HTMLElement>('*')) {
|
|
331
|
+
expect(element.classList.contains('sticky')).toBe(false);
|
|
332
|
+
expect(getComputedStyle(element).position).not.toBe('sticky');
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it.each(['h2', 'h3'] as const)(
|
|
337
|
+
'labels the section with its %s heading and shows count 0 without fixture actions or description',
|
|
338
|
+
(headingLevel) => {
|
|
339
|
+
render(<SubordinateList {...props} headingLevel={headingLevel} count={0} />);
|
|
340
|
+
const region = screen.getByRole('region', { name: 'History' });
|
|
341
|
+
const heading = within(region).getByRole('heading', {
|
|
342
|
+
name: 'History',
|
|
343
|
+
level: headingLevel === 'h2' ? 2 : 3,
|
|
344
|
+
});
|
|
345
|
+
expect(region).toHaveAttribute('aria-labelledby', heading.id);
|
|
346
|
+
expect(within(region).getByText('0')).toBeVisible();
|
|
347
|
+
expect(within(region).queryByRole('button')).not.toBeInTheDocument();
|
|
348
|
+
expect(region).not.toHaveTextContent(/Add policy|Guardrails|deployments/i);
|
|
349
|
+
},
|
|
350
|
+
);
|
|
351
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useId, type ReactNode } from 'react';
|
|
2
|
+
import { SectionHeader } from '../../page-chrome/SectionHeader/SectionHeader';
|
|
3
|
+
import { TableSkeleton } from '../../feedback/Skeletons/Skeletons';
|
|
4
|
+
import { ErrorPanel } from '../../feedback/ErrorPanel/ErrorPanel';
|
|
5
|
+
import { ServerCrash } from '@gntik-ai/icons';
|
|
6
|
+
import { DataTable } from '../DataTable/DataTable';
|
|
7
|
+
import type { DataTableColumn } from '../DataTable/data-table-utils';
|
|
8
|
+
import { PaginationFooter } from '../PaginationFooter/PaginationFooter';
|
|
9
|
+
import { useI18n } from '@gntik-ai/ui';
|
|
10
|
+
|
|
11
|
+
export interface SubordinateListPagination {
|
|
12
|
+
/** Positive server page size. */
|
|
13
|
+
limit: number;
|
|
14
|
+
/** Zero-based server offset. */
|
|
15
|
+
offset: number;
|
|
16
|
+
total: number;
|
|
17
|
+
onPageChange: (offset: number) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface SubordinateListError {
|
|
21
|
+
title: string;
|
|
22
|
+
message: string;
|
|
23
|
+
/** null hides the error code chip. */
|
|
24
|
+
code: string | number | null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SubordinateListProps<T> {
|
|
28
|
+
title: string;
|
|
29
|
+
headingLevel: 'h2' | 'h3';
|
|
30
|
+
/** Server total, or the length of an unpaginated collection (including zero). */
|
|
31
|
+
count: number;
|
|
32
|
+
columns: ReadonlyArray<DataTableColumn<T>>;
|
|
33
|
+
rows: readonly T[];
|
|
34
|
+
getRowId: (row: T) => string;
|
|
35
|
+
pagination: SubordinateListPagination | null;
|
|
36
|
+
loading: boolean;
|
|
37
|
+
error: SubordinateListError | null;
|
|
38
|
+
onRetry: () => void | Promise<void>;
|
|
39
|
+
/** Host-supplied EmptyStates composition. */
|
|
40
|
+
emptyState: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Read-only list section with explicit host data and no demo defaults. */
|
|
44
|
+
export function SubordinateList<T>({
|
|
45
|
+
title,
|
|
46
|
+
headingLevel,
|
|
47
|
+
count,
|
|
48
|
+
columns,
|
|
49
|
+
rows,
|
|
50
|
+
getRowId,
|
|
51
|
+
pagination,
|
|
52
|
+
loading,
|
|
53
|
+
error,
|
|
54
|
+
onRetry,
|
|
55
|
+
emptyState,
|
|
56
|
+
}: SubordinateListProps<T>) {
|
|
57
|
+
const headingId = useId();
|
|
58
|
+
const { locale, t } = useI18n();
|
|
59
|
+
return (
|
|
60
|
+
<section aria-labelledby={headingId} aria-busy={loading} className="space-y-4">
|
|
61
|
+
<SectionHeader
|
|
62
|
+
title={title}
|
|
63
|
+
as={headingLevel}
|
|
64
|
+
count={count}
|
|
65
|
+
description={null}
|
|
66
|
+
actions={[]}
|
|
67
|
+
bordered={true}
|
|
68
|
+
headingId={headingId}
|
|
69
|
+
className=""
|
|
70
|
+
/>
|
|
71
|
+
{error !== null ? (
|
|
72
|
+
<ErrorPanel
|
|
73
|
+
icon={ServerCrash}
|
|
74
|
+
title={error.title}
|
|
75
|
+
message={error.message}
|
|
76
|
+
code={error.code}
|
|
77
|
+
requestId=""
|
|
78
|
+
details=""
|
|
79
|
+
onRetry={onRetry}
|
|
80
|
+
retrying={undefined}
|
|
81
|
+
retryLabel={t('error.retry')}
|
|
82
|
+
secondaryAction={null}
|
|
83
|
+
titleAs="h3"
|
|
84
|
+
className=""
|
|
85
|
+
/>
|
|
86
|
+
) : loading ? (
|
|
87
|
+
<TableSkeleton rows={pagination?.limit ?? 5} columns={columns.length} label={t('loading.table')} className="" />
|
|
88
|
+
) : rows.length === 0 ? (
|
|
89
|
+
emptyState
|
|
90
|
+
) : (
|
|
91
|
+
<DataTable
|
|
92
|
+
rows={rows}
|
|
93
|
+
columns={columns.map((column) => ({
|
|
94
|
+
...column,
|
|
95
|
+
sortable: false,
|
|
96
|
+
editable: false,
|
|
97
|
+
}))}
|
|
98
|
+
getRowId={getRowId}
|
|
99
|
+
caption={title}
|
|
100
|
+
showCaption={false}
|
|
101
|
+
paginated={false}
|
|
102
|
+
selectable={false}
|
|
103
|
+
selectedIds={[]}
|
|
104
|
+
selectionSummary={false}
|
|
105
|
+
sort={null}
|
|
106
|
+
defaultSort={null}
|
|
107
|
+
manualSorting={true}
|
|
108
|
+
showColumnMenu={false}
|
|
109
|
+
showDensityToggle={false}
|
|
110
|
+
showViewSwitcher={false}
|
|
111
|
+
resizable={false}
|
|
112
|
+
pinnedColumns={{}}
|
|
113
|
+
showPinMenu={false}
|
|
114
|
+
virtualize={false}
|
|
115
|
+
hiddenColumns={[]}
|
|
116
|
+
toolbar={null}
|
|
117
|
+
loading={false}
|
|
118
|
+
loadingRows={0}
|
|
119
|
+
emptyState={emptyState}
|
|
120
|
+
className=""
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
{error === null && !loading && pagination !== null && (
|
|
124
|
+
<PaginationFooter
|
|
125
|
+
total={pagination.total}
|
|
126
|
+
page={Math.floor(pagination.offset / pagination.limit) + 1}
|
|
127
|
+
defaultPage={1}
|
|
128
|
+
onPageChange={(page) => pagination.onPageChange((page - 1) * pagination.limit)}
|
|
129
|
+
pageSize={pagination.limit}
|
|
130
|
+
defaultPageSize={pagination.limit}
|
|
131
|
+
onPageSizeChange={() => {}}
|
|
132
|
+
pageSizeOptions={[pagination.limit]}
|
|
133
|
+
noun={title}
|
|
134
|
+
locale={locale}
|
|
135
|
+
className=""
|
|
136
|
+
/>
|
|
137
|
+
)}
|
|
138
|
+
</section>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BlockMeta } from '../../meta';
|
|
2
|
+
|
|
3
|
+
export const meta: BlockMeta = {
|
|
4
|
+
name: 'Subordinate list',
|
|
5
|
+
family: 'tables',
|
|
6
|
+
status: 'beta',
|
|
7
|
+
description:
|
|
8
|
+
'Read-only list section inside a resource-form host, composing section-header, data-table, pagination-footer, empty-states, skeletons and error-panel. All props are required: title (string), headingLevel (h2 or h3), count (number, including 0), columns (typed DataTableColumn<T>[]), rows (readonly T[]), getRowId, pagination ({limit, offset, total, onPageChange(offset)} or null), loading (boolean), error ({title, message, code: string | number | null} or null), onRetry and emptyState (host-supplied ReactNode). Every supplied row renders; server pagination converts the zero-based offset to a 1-based footer page and fixes pageSizeOptions to [limit]. No filtering, sorting, selection, create action, toolbar, virtualization, pinning or sticky region. Error takes precedence over loading, then empty and data; retry uses the current i18n locale. Error headings use h3 for either section heading level. Composition example: packages/blocks/src/tables/SubordinateList/examples/ResourceForm.tsx uses the resource-form form sections and sticky save bar with a server-paginated History section and an unpaginated Consumers section.',
|
|
9
|
+
uses: ['section-header', 'data-table', 'pagination-footer', 'empty-states', 'skeletons', 'error-panel'],
|
|
10
|
+
};
|