@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,480 @@
|
|
|
1
|
+
import { Profiler, useState } from 'react';
|
|
2
|
+
import { fireEvent, render, screen, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { FlowStatusBadge } from '@gntik-ai/flow';
|
|
5
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
6
|
+
import * as blocks from '../../index';
|
|
7
|
+
import { FlowBuilder, type ConsoleEntry, type FlowEdge, type FlowNode } from './FlowBuilder';
|
|
8
|
+
|
|
9
|
+
// React Flow in jsdom reads the zoom from DOMMatrixReadOnly and node sizes from offset*.
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
if (!('DOMMatrixReadOnly' in window)) {
|
|
12
|
+
(window as unknown as { DOMMatrixReadOnly: unknown }).DOMMatrixReadOnly = class {
|
|
13
|
+
m22 = 1;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperties(HTMLElement.prototype, {
|
|
17
|
+
offsetHeight: { configurable: true, get: () => 90 },
|
|
18
|
+
offsetWidth: { configurable: true, get: () => 208 },
|
|
19
|
+
});
|
|
20
|
+
document.documentElement.style.setProperty('--primary', '145 61% 50%');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
function setWide(matches: boolean) {
|
|
24
|
+
const original = window.matchMedia;
|
|
25
|
+
window.matchMedia = ((query: string) => ({ ...original(query), matches })) as typeof window.matchMedia;
|
|
26
|
+
return () => (window.matchMedia = original);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe('FlowBuilder', () => {
|
|
30
|
+
it('renders palette, canvas, inspector and console; resizable on wide screens', async () => {
|
|
31
|
+
const restore = setWide(true);
|
|
32
|
+
try {
|
|
33
|
+
render(<FlowBuilder />);
|
|
34
|
+
const canvas = screen.getByRole('region', { name: 'Untitled flow canvas' });
|
|
35
|
+
expect(canvas.querySelectorAll('.react-flow__node')).toHaveLength(5);
|
|
36
|
+
expect(screen.getAllByRole('separator')).toHaveLength(3);
|
|
37
|
+
expect(screen.getByText('Select a node to edit its fields.')).toBeInTheDocument();
|
|
38
|
+
expect(screen.getByRole('log', { name: 'Run console' })).toHaveTextContent('Validation passed');
|
|
39
|
+
await expectNoAxeViolations();
|
|
40
|
+
} finally {
|
|
41
|
+
restore();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('adds a node from the palette, edits it in the inspector and runs the flow', async () => {
|
|
46
|
+
const user = userEvent.setup();
|
|
47
|
+
// Existing consumers can keep callbacks typed with the default built-in FlowNode.
|
|
48
|
+
const onRun = vi.fn<(graph: { nodes: FlowNode[]; edges: FlowEdge[] }) => void>();
|
|
49
|
+
render(<FlowBuilder onRun={onRun} />);
|
|
50
|
+
expect(screen.queryAllByRole('separator')).toHaveLength(0); // stacked on small screens
|
|
51
|
+
await user.click(screen.getByRole('button', { name: /Add Step/ }));
|
|
52
|
+
const canvas = screen.getByRole('region', { name: 'Untitled flow canvas' });
|
|
53
|
+
expect(canvas.querySelectorAll('.react-flow__node')).toHaveLength(6);
|
|
54
|
+
const titleInput = screen.getByRole('textbox', { name: 'Title' });
|
|
55
|
+
expect(titleInput).toHaveValue('New step');
|
|
56
|
+
fireEvent.change(titleInput, { target: { value: 'Enrich record' } });
|
|
57
|
+
expect(within(canvas).getByText('Enrich record')).toBeInTheDocument();
|
|
58
|
+
|
|
59
|
+
await user.click(screen.getByRole('button', { name: 'Run' }));
|
|
60
|
+
expect(onRun).toHaveBeenCalledWith(
|
|
61
|
+
expect.objectContaining({
|
|
62
|
+
nodes: expect.any(Array),
|
|
63
|
+
edges: expect.any(Array),
|
|
64
|
+
}),
|
|
65
|
+
);
|
|
66
|
+
const log = screen.getByRole('log', { name: 'Run console' });
|
|
67
|
+
expect(log).toHaveTextContent('Run #1 started · 6 nodes');
|
|
68
|
+
expect(log).toHaveTextContent(/Enrich record completed/);
|
|
69
|
+
|
|
70
|
+
await user.click(screen.getByRole('button', { name: 'Delete node' }));
|
|
71
|
+
expect(canvas.querySelectorAll('.react-flow__node')).toHaveLength(5);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('appends entries returned by onRun and starts from defaultConsoleEntries', async () => {
|
|
75
|
+
const user = userEvent.setup();
|
|
76
|
+
const entry: ConsoleEntry = { id: 'x', time: '10:00:00', level: 'success', message: 'Deployed run' };
|
|
77
|
+
render(<FlowBuilder defaultConsoleEntries={[]} onRun={() => [entry]} />);
|
|
78
|
+
const log = screen.getByRole('log', { name: 'Run console' });
|
|
79
|
+
expect(log).toHaveTextContent('No output yet');
|
|
80
|
+
await user.click(screen.getByRole('button', { name: 'Run' }));
|
|
81
|
+
expect(log).toHaveTextContent('Deployed run');
|
|
82
|
+
expect(log).not.toHaveTextContent('Run #1 started');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('awaits a promise from onRun and logs a rejection as an error', async () => {
|
|
86
|
+
const user = userEvent.setup();
|
|
87
|
+
let resolve: (v: ConsoleEntry[]) => void = () => {};
|
|
88
|
+
const onRun = vi
|
|
89
|
+
.fn()
|
|
90
|
+
.mockReturnValueOnce(new Promise<ConsoleEntry[]>((r) => (resolve = r)))
|
|
91
|
+
.mockImplementationOnce(() => Promise.reject(new Error('Worker offline')));
|
|
92
|
+
render(<FlowBuilder defaultConsoleEntries={[]} onRun={onRun} />);
|
|
93
|
+
const button = screen.getByRole('button', { name: 'Run' });
|
|
94
|
+
await user.click(button);
|
|
95
|
+
expect(button).toHaveAttribute('aria-busy', 'true');
|
|
96
|
+
resolve([{ id: 'a', time: '10:00:00', level: 'info', message: 'Remote run queued' }]);
|
|
97
|
+
const log = screen.getByRole('log', { name: 'Run console' });
|
|
98
|
+
expect(await within(log).findByText('Remote run queued')).toBeInTheDocument();
|
|
99
|
+
await user.click(screen.getByRole('button', { name: 'Run' }));
|
|
100
|
+
expect(await within(log).findByText('Run #2 failed: Worker offline')).toBeInTheDocument();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('supports a controlled console with onConsoleChange and onConsoleClear', async () => {
|
|
104
|
+
const user = userEvent.setup();
|
|
105
|
+
const onConsoleClear = vi.fn();
|
|
106
|
+
const changes: ConsoleEntry[][] = [];
|
|
107
|
+
function Host() {
|
|
108
|
+
const [entries, setEntries] = useState<ConsoleEntry[]>([
|
|
109
|
+
{ id: 'h', time: '09:00:00', level: 'info', message: 'From host' },
|
|
110
|
+
]);
|
|
111
|
+
return (
|
|
112
|
+
<FlowBuilder
|
|
113
|
+
consoleEntries={entries}
|
|
114
|
+
onConsoleChange={(next) => {
|
|
115
|
+
changes.push(next);
|
|
116
|
+
setEntries(next);
|
|
117
|
+
}}
|
|
118
|
+
onConsoleClear={onConsoleClear}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
render(<Host />);
|
|
123
|
+
const log = screen.getByRole('log', { name: 'Run console' });
|
|
124
|
+
expect(log).toHaveTextContent('From host');
|
|
125
|
+
expect(log).not.toHaveTextContent('Validation passed');
|
|
126
|
+
await user.click(screen.getByRole('button', { name: 'Run' }));
|
|
127
|
+
expect(log).toHaveTextContent('From host');
|
|
128
|
+
expect(log).toHaveTextContent('Run #1 started');
|
|
129
|
+
await user.click(screen.getByRole('button', { name: 'Clear' }));
|
|
130
|
+
expect(onConsoleClear).toHaveBeenCalledOnce();
|
|
131
|
+
expect(changes.at(-1)).toEqual([]);
|
|
132
|
+
expect(log).toHaveTextContent('No output yet');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('keeps a controlled console unchanged without onConsoleChange', async () => {
|
|
136
|
+
const user = userEvent.setup();
|
|
137
|
+
render(<FlowBuilder consoleEntries={[{ id: 'h', time: '09:00:00', level: 'info', message: 'Pinned' }]} />);
|
|
138
|
+
await user.click(screen.getByRole('button', { name: 'Clear' }));
|
|
139
|
+
expect(screen.getByRole('log', { name: 'Run console' })).toHaveTextContent('Pinned');
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('renders its title and panel titles at the requested levels', () => {
|
|
143
|
+
render(<FlowBuilder titleAs="h3" />);
|
|
144
|
+
expect(screen.getByRole('heading', { level: 3, name: 'Untitled flow' })).toBeInTheDocument();
|
|
145
|
+
expect(screen.getByRole('heading', { level: 4, name: 'Run console' })).toBeInTheDocument();
|
|
146
|
+
expect(screen.getByRole('heading', { level: 4, name: 'Nodes' })).toBeInTheDocument();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('re-exports the graph types and sub-parts from the package entry', () => {
|
|
150
|
+
const node: FlowNode = { id: 'n', type: 'step', position: { x: 0, y: 0 }, data: { title: 'Step' } };
|
|
151
|
+
const edge: FlowEdge = { id: 'e', source: 'n', target: 'n' };
|
|
152
|
+
expect([node.id, edge.id]).toEqual(['n', 'e']);
|
|
153
|
+
expect(typeof blocks.NodePalette).toBe('function');
|
|
154
|
+
expect(typeof blocks.NodeInspector).toBe('function');
|
|
155
|
+
expect(typeof blocks.RunConsole).toBe('function');
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
function connectHandles(sourceId: string, handleId: string, targetId: string) {
|
|
160
|
+
const source = document.querySelector(`[data-nodeid="${sourceId}"][data-handleid="${handleId}"]`);
|
|
161
|
+
const target = document.querySelector(`[data-nodeid="${targetId}"].target`);
|
|
162
|
+
if (!source || !target) throw new Error('Named connection handles missing');
|
|
163
|
+
// jsdom has no hit testing: the browser boundary returns the handle under the pointer.
|
|
164
|
+
Object.defineProperty(document, 'elementFromPoint', {
|
|
165
|
+
configurable: true,
|
|
166
|
+
value: () => target,
|
|
167
|
+
});
|
|
168
|
+
fireEvent.click(source);
|
|
169
|
+
fireEvent.click(target);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
it('preserves built-in node kinds in the public inspector props', () => {
|
|
173
|
+
const node: NonNullable<blocks.NodeInspectorProps['node']> = {
|
|
174
|
+
id: 'step',
|
|
175
|
+
type: 'step',
|
|
176
|
+
position: { x: 0, y: 0 },
|
|
177
|
+
data: { title: 'Step' },
|
|
178
|
+
};
|
|
179
|
+
const kind: import('@gntik-ai/flow').FlowNodeKind = node.type;
|
|
180
|
+
expect(kind).toBe('step');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it.each([
|
|
184
|
+
['branch', 'arm-0', 'branch-arm', { armIndex: 0 }],
|
|
185
|
+
['parallel', 'branch', 'parallel', { branch: 'first' }],
|
|
186
|
+
['sequence', 'next', 'sequence', { step: 1 }],
|
|
187
|
+
] as const)('maps a %s named handle to the consumer edge type and data', async (type, handle, edgeType, data) => {
|
|
188
|
+
const onRun = vi.fn();
|
|
189
|
+
const mapper = vi.fn(() => ({ type: edgeType, data }));
|
|
190
|
+
render(
|
|
191
|
+
<FlowBuilder
|
|
192
|
+
edges={[]}
|
|
193
|
+
nodes={[
|
|
194
|
+
{
|
|
195
|
+
id: 'source',
|
|
196
|
+
type,
|
|
197
|
+
position: { x: 0, y: 0 },
|
|
198
|
+
data: { title: 'Source' },
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'target',
|
|
202
|
+
type: 'output',
|
|
203
|
+
position: { x: 256, y: 0 },
|
|
204
|
+
data: { title: 'Target' },
|
|
205
|
+
},
|
|
206
|
+
]}
|
|
207
|
+
nodeTypes={[
|
|
208
|
+
{
|
|
209
|
+
type,
|
|
210
|
+
handles: [{ id: handle, kind: 'source' }],
|
|
211
|
+
render: ({ data }) => <span>{data.title}</span>,
|
|
212
|
+
},
|
|
213
|
+
]}
|
|
214
|
+
onConnectEdge={mapper}
|
|
215
|
+
onRun={onRun}
|
|
216
|
+
/>,
|
|
217
|
+
);
|
|
218
|
+
connectHandles('source', handle, 'target');
|
|
219
|
+
await userEvent.click(screen.getByRole('button', { name: 'Run' }));
|
|
220
|
+
expect(mapper).toHaveBeenCalledWith({
|
|
221
|
+
source: 'source',
|
|
222
|
+
target: 'target',
|
|
223
|
+
sourceHandle: handle,
|
|
224
|
+
targetHandle: null,
|
|
225
|
+
sourceType: type,
|
|
226
|
+
targetType: 'output',
|
|
227
|
+
});
|
|
228
|
+
expect(onRun.mock.calls[0]?.[0].edges).toEqual([
|
|
229
|
+
expect.objectContaining({
|
|
230
|
+
source: 'source',
|
|
231
|
+
target: 'target',
|
|
232
|
+
type: edgeType,
|
|
233
|
+
data,
|
|
234
|
+
}),
|
|
235
|
+
]);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('rejects a connection without mapping, notifying acceptance or adding an edge', async () => {
|
|
239
|
+
const rejection = {
|
|
240
|
+
code: 'cycle',
|
|
241
|
+
nodeId: 'a',
|
|
242
|
+
message: 'Cycles are not allowed',
|
|
243
|
+
};
|
|
244
|
+
const rejected = vi.fn();
|
|
245
|
+
const accepted = vi.fn();
|
|
246
|
+
const mapper = vi.fn();
|
|
247
|
+
const onRun = vi.fn();
|
|
248
|
+
render(
|
|
249
|
+
<FlowBuilder
|
|
250
|
+
nodes={[
|
|
251
|
+
{
|
|
252
|
+
id: 'a',
|
|
253
|
+
type: 'branch',
|
|
254
|
+
position: { x: 0, y: 0 },
|
|
255
|
+
data: { title: 'Branch' },
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: 'b',
|
|
259
|
+
type: 'output',
|
|
260
|
+
position: { x: 256, y: 0 },
|
|
261
|
+
data: { title: 'End' },
|
|
262
|
+
},
|
|
263
|
+
]}
|
|
264
|
+
edges={[]}
|
|
265
|
+
nodeTypes={[
|
|
266
|
+
{
|
|
267
|
+
type: 'branch',
|
|
268
|
+
handles: [{ id: 'arm', kind: 'source' }],
|
|
269
|
+
render: ({ data }) => <span>{data.title}</span>,
|
|
270
|
+
},
|
|
271
|
+
]}
|
|
272
|
+
isValidConnection={() => rejection}
|
|
273
|
+
onConnectionRejected={rejected}
|
|
274
|
+
onConnect={accepted}
|
|
275
|
+
onConnectEdge={mapper}
|
|
276
|
+
onRun={onRun}
|
|
277
|
+
/>,
|
|
278
|
+
);
|
|
279
|
+
connectHandles('a', 'arm', 'b');
|
|
280
|
+
expect(rejected).toHaveBeenCalledExactlyOnceWith(rejection);
|
|
281
|
+
expect(accepted).not.toHaveBeenCalled();
|
|
282
|
+
expect(mapper).not.toHaveBeenCalled();
|
|
283
|
+
await userEvent.click(screen.getByRole('button', { name: 'Run' }));
|
|
284
|
+
expect(onRun.mock.calls[0]?.[0].edges).toEqual([]);
|
|
285
|
+
expect(screen.queryByRole('list', { name: 'Flow problems' })).toBeNull();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
it('decorates invalid nodes with an icon and text and focuses a problem node', async () => {
|
|
289
|
+
render(
|
|
290
|
+
<FlowBuilder
|
|
291
|
+
validationIssues={[
|
|
292
|
+
{ code: 'required', nodeId: 'validate', message: 'Schema is required' },
|
|
293
|
+
{ code: 'empty-flow', message: 'Add a terminal step' },
|
|
294
|
+
]}
|
|
295
|
+
/>,
|
|
296
|
+
);
|
|
297
|
+
const node = screen.getByTestId('rf__node-validate');
|
|
298
|
+
expect(within(node).getByText('Schema is required')).toBeInTheDocument();
|
|
299
|
+
expect(node.querySelector('svg[aria-hidden]')).not.toBeNull();
|
|
300
|
+
const problems = screen.getByRole('list', { name: 'Flow problems' });
|
|
301
|
+
expect(within(problems).getByText(/Add a terminal step/).tagName).toBe('SPAN');
|
|
302
|
+
await userEvent.click(within(problems).getByRole('button', { name: /Schema is required/ }));
|
|
303
|
+
expect(node).toHaveClass('selected');
|
|
304
|
+
expect(node).toHaveFocus();
|
|
305
|
+
expect(screen.getByRole('textbox', { name: 'Title' })).toHaveValue('Validate payload');
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('run mode keeps labelled nodes selectable with live status but prevents editing', async () => {
|
|
309
|
+
const selected = vi.fn();
|
|
310
|
+
const { rerender } = render(
|
|
311
|
+
<FlowBuilder mode="run" nodeStatus={{ webhook: 'running', validate: 'paused' }} onNodeSelect={selected} />,
|
|
312
|
+
);
|
|
313
|
+
expect(screen.queryByRole('button', { name: /Add Step/ })).toBeNull();
|
|
314
|
+
expect(screen.queryByRole('button', { name: 'Run' })).toBeNull();
|
|
315
|
+
const node = screen.getByRole('group', { name: 'Webhook' });
|
|
316
|
+
expect(node).toHaveAttribute('tabindex', '0');
|
|
317
|
+
expect(node).not.toHaveClass('draggable');
|
|
318
|
+
expect(node.querySelector('.connectable')).toBeNull();
|
|
319
|
+
expect(within(node).getByText('Running')).toBeInTheDocument();
|
|
320
|
+
fireEvent.click(node);
|
|
321
|
+
expect(selected).toHaveBeenLastCalledWith('webhook');
|
|
322
|
+
expect(screen.queryByRole('textbox', { name: 'Title' })).toBeNull();
|
|
323
|
+
expect(screen.queryByRole('button', { name: 'Delete node' })).toBeNull();
|
|
324
|
+
const other = screen.getByRole('group', { name: 'Validate payload' });
|
|
325
|
+
fireEvent.keyDown(other, { key: 'Enter' });
|
|
326
|
+
expect(selected).toHaveBeenLastCalledWith('validate');
|
|
327
|
+
fireEvent.click(other);
|
|
328
|
+
await userEvent.keyboard('{Backspace}');
|
|
329
|
+
expect(other).toBeInTheDocument();
|
|
330
|
+
rerender(<FlowBuilder mode="run" nodeStatus={{ webhook: 'done', validate: 'paused' }} onNodeSelect={selected} />);
|
|
331
|
+
expect(within(node).getByText('Done')).toBeInTheDocument();
|
|
332
|
+
expect(within(other).getByText('Paused')).toBeInTheDocument();
|
|
333
|
+
await expectNoAxeViolations();
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it('keeps viewport navigation available for a large run graph', () => {
|
|
337
|
+
const restore = setWide(true);
|
|
338
|
+
try {
|
|
339
|
+
render(<FlowBuilder mode="run" />);
|
|
340
|
+
const canvas = screen.getByRole('region', { name: 'Untitled flow canvas' });
|
|
341
|
+
expect(within(canvas).getByRole('button', { name: 'Zoom In' })).toBeInTheDocument();
|
|
342
|
+
expect(within(canvas).getByRole('button', { name: 'Zoom Out' })).toBeInTheDocument();
|
|
343
|
+
expect(canvas.querySelector('.react-flow__minimap')).not.toBeNull();
|
|
344
|
+
expect(canvas.querySelector('.react-flow__pane')).toHaveClass('draggable');
|
|
345
|
+
expect(screen.queryByRole('button', { name: 'Toggle Interactivity' })).toBeNull();
|
|
346
|
+
} finally {
|
|
347
|
+
restore();
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('updating one status does not render another node badge subtree', () => {
|
|
352
|
+
const renders: Record<string, number> = {};
|
|
353
|
+
const nodes: FlowNode<string>[] = ['one', 'two'].map((id) => ({
|
|
354
|
+
id,
|
|
355
|
+
type: 'custom',
|
|
356
|
+
position: { x: id === 'one' ? 0 : 256, y: 0 },
|
|
357
|
+
data: { title: id },
|
|
358
|
+
}));
|
|
359
|
+
const types = [
|
|
360
|
+
{
|
|
361
|
+
type: 'custom',
|
|
362
|
+
handles: [],
|
|
363
|
+
decorations: 'consumer' as const,
|
|
364
|
+
render: ({ id, data }: import('@gntik-ai/flow').FlowNodeRenderProps) => (
|
|
365
|
+
<Profiler
|
|
366
|
+
id={id}
|
|
367
|
+
onRender={(id) => {
|
|
368
|
+
renders[id] = (renders[id] ?? 0) + 1;
|
|
369
|
+
}}
|
|
370
|
+
>
|
|
371
|
+
<FlowStatusBadge status={data.decoration?.status ?? 'paused'} />
|
|
372
|
+
</Profiler>
|
|
373
|
+
),
|
|
374
|
+
},
|
|
375
|
+
];
|
|
376
|
+
const { rerender } = render(
|
|
377
|
+
<FlowBuilder
|
|
378
|
+
nodes={nodes}
|
|
379
|
+
edges={[]}
|
|
380
|
+
nodeTypes={types}
|
|
381
|
+
mode="run"
|
|
382
|
+
nodeStatus={{ one: 'running', two: 'paused' }}
|
|
383
|
+
/>,
|
|
384
|
+
);
|
|
385
|
+
const before = renders.two;
|
|
386
|
+
rerender(
|
|
387
|
+
<FlowBuilder nodes={nodes} edges={[]} nodeTypes={types} mode="run" nodeStatus={{ one: 'done', two: 'paused' }} />,
|
|
388
|
+
);
|
|
389
|
+
expect(renders.two).toBe(before);
|
|
390
|
+
expect(screen.getAllByText('Done')).toHaveLength(1);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('anchors a connection rejection to its source when the validator omits a node id', () => {
|
|
394
|
+
const rejected = vi.fn();
|
|
395
|
+
render(
|
|
396
|
+
<FlowBuilder
|
|
397
|
+
nodes={[
|
|
398
|
+
{ id: 'a', type: 'branch', position: { x: 0, y: 0 }, data: { title: 'Branch' } },
|
|
399
|
+
{ id: 'b', type: 'output', position: { x: 256, y: 0 }, data: { title: 'End' } },
|
|
400
|
+
]}
|
|
401
|
+
edges={[]}
|
|
402
|
+
nodeTypes={[
|
|
403
|
+
{ type: 'branch', handles: [{ id: 'arm', kind: 'source' }], render: ({ data }) => <span>{data.title}</span> },
|
|
404
|
+
]}
|
|
405
|
+
isValidConnection={() => ({ code: 'invalid', message: 'Choose another target' })}
|
|
406
|
+
onConnectionRejected={rejected}
|
|
407
|
+
/>,
|
|
408
|
+
);
|
|
409
|
+
connectHandles('a', 'arm', 'b');
|
|
410
|
+
expect(rejected).toHaveBeenCalledExactlyOnceWith({ code: 'invalid', nodeId: 'a', message: 'Choose another target' });
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it('lets the consumer own and clear rejection problems without duplicates', async () => {
|
|
414
|
+
function Consumer() {
|
|
415
|
+
const [issues, setIssues] = useState<import('./FlowBuilder').FlowValidationIssue[]>([]);
|
|
416
|
+
return (
|
|
417
|
+
<>
|
|
418
|
+
<FlowBuilder
|
|
419
|
+
nodes={[
|
|
420
|
+
{ id: 'a', type: 'branch', position: { x: 0, y: 0 }, data: { title: 'Branch' } },
|
|
421
|
+
{ id: 'b', type: 'output', position: { x: 256, y: 0 }, data: { title: 'End' } },
|
|
422
|
+
]}
|
|
423
|
+
edges={[]}
|
|
424
|
+
nodeTypes={[
|
|
425
|
+
{
|
|
426
|
+
type: 'branch',
|
|
427
|
+
handles: [{ id: 'arm', kind: 'source' }],
|
|
428
|
+
render: ({ data }) => <span>{data.title}</span>,
|
|
429
|
+
},
|
|
430
|
+
]}
|
|
431
|
+
isValidConnection={() => ({ code: 'cycle', message: 'Cycles are not allowed' })}
|
|
432
|
+
onConnectionRejected={(issue) => setIssues([issue])}
|
|
433
|
+
validationIssues={issues}
|
|
434
|
+
/>
|
|
435
|
+
<button onClick={() => setIssues([])}>Clear problems</button>
|
|
436
|
+
</>
|
|
437
|
+
);
|
|
438
|
+
}
|
|
439
|
+
render(<Consumer />);
|
|
440
|
+
connectHandles('a', 'arm', 'b');
|
|
441
|
+
expect(screen.getByRole('list', { name: 'Flow problems' }).children).toHaveLength(1);
|
|
442
|
+
await userEvent.click(screen.getByRole('button', { name: 'Clear problems' }));
|
|
443
|
+
expect(screen.queryByRole('list', { name: 'Flow problems' })).toBeNull();
|
|
444
|
+
expect(screen.queryByText('Cycles are not allowed')).toBeNull();
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
it('connects named custom handles with the keyboard', async () => {
|
|
448
|
+
const onRun = vi.fn();
|
|
449
|
+
render(
|
|
450
|
+
<FlowBuilder
|
|
451
|
+
nodes={[
|
|
452
|
+
{ id: 'a', type: 'custom', width: 208, height: 90, position: { x: 0, y: 0 }, data: { title: 'Source' } },
|
|
453
|
+
{ id: 'b', type: 'custom', width: 208, height: 90, position: { x: 256, y: 0 }, data: { title: 'Target' } },
|
|
454
|
+
]}
|
|
455
|
+
edges={[]}
|
|
456
|
+
nodeTypes={[
|
|
457
|
+
{
|
|
458
|
+
type: 'custom',
|
|
459
|
+
handles: [
|
|
460
|
+
{ id: 'input', kind: 'target', label: 'Input' },
|
|
461
|
+
{ id: 'next', kind: 'source', label: 'Next' },
|
|
462
|
+
],
|
|
463
|
+
render: ({ data }) => <span>{data.title}</span>,
|
|
464
|
+
},
|
|
465
|
+
]}
|
|
466
|
+
onRun={onRun}
|
|
467
|
+
/>,
|
|
468
|
+
);
|
|
469
|
+
const source = within(screen.getByTestId('rf__node-a')).getByRole('button', { name: 'Next' });
|
|
470
|
+
const target = within(screen.getByTestId('rf__node-b')).getByRole('button', { name: 'Input' });
|
|
471
|
+
Object.defineProperty(document, 'elementFromPoint', { configurable: true, value: () => target });
|
|
472
|
+
expect(source).toHaveAttribute('tabindex', '0');
|
|
473
|
+
fireEvent.keyDown(source, { key: 'Enter' });
|
|
474
|
+
fireEvent.keyDown(target, { key: ' ' });
|
|
475
|
+
await userEvent.click(screen.getByRole('button', { name: 'Run' }));
|
|
476
|
+
expect(onRun.mock.calls[0]?.[0].edges).toEqual([
|
|
477
|
+
expect.objectContaining({ source: 'a', target: 'b', sourceHandle: 'next', targetHandle: 'input' }),
|
|
478
|
+
]);
|
|
479
|
+
await expectNoAxeViolations();
|
|
480
|
+
});
|