@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,223 @@
|
|
|
1
|
+
import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';
|
|
2
|
+
import { cn, useI18n } from '@gntik-ai/ui';
|
|
3
|
+
import { CalendarHeader } from '../shared/CalendarHeader';
|
|
4
|
+
import {
|
|
5
|
+
addDays,
|
|
6
|
+
addMonths,
|
|
7
|
+
dayKey,
|
|
8
|
+
formatFullDate,
|
|
9
|
+
formatMonth,
|
|
10
|
+
formatTime,
|
|
11
|
+
formatWeekday,
|
|
12
|
+
monthGrid,
|
|
13
|
+
sameDay,
|
|
14
|
+
sameMonth,
|
|
15
|
+
startOfDay,
|
|
16
|
+
startOfMonth,
|
|
17
|
+
startOfWeek,
|
|
18
|
+
} from '../shared/dates';
|
|
19
|
+
import { defaultEventKinds, groupByDay, kindOf, TONE, type EventKind, type ScheduleEvent } from '../shared/events';
|
|
20
|
+
import { sampleEvents, sampleToday } from '../shared/fixtures';
|
|
21
|
+
|
|
22
|
+
export interface MonthCalendarProps {
|
|
23
|
+
events?: ScheduleEvent[];
|
|
24
|
+
/** The app's "today" (the block never reads the clock). */
|
|
25
|
+
today?: Date;
|
|
26
|
+
/** Month shown first (uncontrolled). Defaults to the month of `today`. */
|
|
27
|
+
defaultMonth?: Date;
|
|
28
|
+
onMonthChange?: (month: Date) => void;
|
|
29
|
+
/** Initially selected day (uncontrolled). */
|
|
30
|
+
defaultSelected?: Date;
|
|
31
|
+
/** Called when a day is activated (click, Enter or Space). */
|
|
32
|
+
onSelectDate?: (date: Date, events: ScheduleEvent[]) => void;
|
|
33
|
+
/** Event kinds (label, icon, tone) by `event.kind`. */
|
|
34
|
+
kinds?: Record<string, EventKind>;
|
|
35
|
+
/** Event lines per day before "+N more". */
|
|
36
|
+
maxEventsPerDay?: number;
|
|
37
|
+
/** Caller actions in the header (e.g. a "Schedule" button). */
|
|
38
|
+
actions?: ReactNode;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Monday-first weekdays (2026-01-05 is a Monday). */
|
|
43
|
+
const WEEK = Array.from({ length: 7 }, (_, i) => new Date(2026, 0, 5 + i));
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Month view of scheduled work: a Monday-first grid with up to N events per day.
|
|
47
|
+
* Keyboard: arrows move by day/week, Home/End to the week edges, PageUp/PageDown by month,
|
|
48
|
+
* Enter/Space selects.
|
|
49
|
+
*/
|
|
50
|
+
export function MonthCalendar({
|
|
51
|
+
events = sampleEvents,
|
|
52
|
+
today = sampleToday,
|
|
53
|
+
defaultMonth,
|
|
54
|
+
onMonthChange,
|
|
55
|
+
defaultSelected,
|
|
56
|
+
onSelectDate,
|
|
57
|
+
kinds = defaultEventKinds,
|
|
58
|
+
maxEventsPerDay = 2,
|
|
59
|
+
actions,
|
|
60
|
+
className,
|
|
61
|
+
}: MonthCalendarProps) {
|
|
62
|
+
const { t, locale, dir } = useI18n();
|
|
63
|
+
const titleId = useId();
|
|
64
|
+
const [selected, setSelected] = useState<Date>(() => startOfDay(defaultSelected ?? today));
|
|
65
|
+
const [focused, setFocused] = useState<Date>(() => startOfDay(defaultSelected ?? defaultMonth ?? today));
|
|
66
|
+
const [month, setMonth] = useState<Date>(() => startOfMonth(defaultMonth ?? defaultSelected ?? today));
|
|
67
|
+
const gridRef = useRef<HTMLDivElement>(null);
|
|
68
|
+
const moveFocus = useRef(false);
|
|
69
|
+
const byDay = useMemo(() => groupByDay(events), [events]);
|
|
70
|
+
const weeks = monthGrid(month);
|
|
71
|
+
// The roving tab stop stays inside the visible month.
|
|
72
|
+
const tabStop = sameMonth(focused, month) ? focused : sameMonth(selected, month) ? selected : month;
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (!moveFocus.current) return;
|
|
76
|
+
moveFocus.current = false;
|
|
77
|
+
gridRef.current?.querySelector<HTMLElement>(`[data-date="${dayKey(focused)}"]`)?.focus();
|
|
78
|
+
}, [focused]);
|
|
79
|
+
|
|
80
|
+
const showMonth = (next: Date) => {
|
|
81
|
+
const first = startOfMonth(next);
|
|
82
|
+
setMonth(first);
|
|
83
|
+
onMonthChange?.(first);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const go = (date: Date) => {
|
|
87
|
+
setFocused(date);
|
|
88
|
+
if (!sameMonth(date, month)) showMonth(date);
|
|
89
|
+
moveFocus.current = true;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const select = (date: Date) => {
|
|
93
|
+
setSelected(date);
|
|
94
|
+
setFocused(date);
|
|
95
|
+
onSelectDate?.(date, byDay.get(dayKey(date)) ?? []);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, date: Date) => {
|
|
99
|
+
const weekStart = startOfWeek(date);
|
|
100
|
+
const map: Record<string, () => Date> = {
|
|
101
|
+
ArrowLeft: () => addDays(date, dir === 'rtl' ? 1 : -1),
|
|
102
|
+
ArrowRight: () => addDays(date, dir === 'rtl' ? -1 : 1),
|
|
103
|
+
ArrowUp: () => addDays(date, -7),
|
|
104
|
+
ArrowDown: () => addDays(date, 7),
|
|
105
|
+
Home: () => weekStart,
|
|
106
|
+
End: () => addDays(weekStart, 6),
|
|
107
|
+
PageUp: () => new Date(date.getFullYear(), date.getMonth() - 1, Math.min(date.getDate(), 28)),
|
|
108
|
+
PageDown: () => new Date(date.getFullYear(), date.getMonth() + 1, Math.min(date.getDate(), 28)),
|
|
109
|
+
};
|
|
110
|
+
const next = map[event.key];
|
|
111
|
+
if (!next) return;
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
go(next());
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<div className={cn('overflow-hidden rounded-xl border border-border bg-card', className)}>
|
|
118
|
+
<CalendarHeader
|
|
119
|
+
titleId={titleId}
|
|
120
|
+
title={formatMonth(month, locale)}
|
|
121
|
+
prevLabel={t('calendar.previousMonth')}
|
|
122
|
+
nextLabel={t('calendar.nextMonth')}
|
|
123
|
+
onPrev={() => showMonth(addMonths(month, -1))}
|
|
124
|
+
onNext={() => showMonth(addMonths(month, 1))}
|
|
125
|
+
onToday={() => {
|
|
126
|
+
showMonth(today);
|
|
127
|
+
setFocused(startOfDay(today));
|
|
128
|
+
}}
|
|
129
|
+
actions={actions}
|
|
130
|
+
/>
|
|
131
|
+
<div ref={gridRef} role="grid" aria-labelledby={titleId}>
|
|
132
|
+
<div role="row" className="grid grid-cols-7 border-b border-border bg-secondary/30">
|
|
133
|
+
{WEEK.map((day) => (
|
|
134
|
+
<div
|
|
135
|
+
key={day.getDay()}
|
|
136
|
+
role="columnheader"
|
|
137
|
+
aria-label={formatWeekday(day, locale, 'long')}
|
|
138
|
+
className="py-2 text-center text-[11px] font-medium tracking-wide text-muted-foreground uppercase"
|
|
139
|
+
>
|
|
140
|
+
{formatWeekday(day, locale)}
|
|
141
|
+
</div>
|
|
142
|
+
))}
|
|
143
|
+
</div>
|
|
144
|
+
{weeks.map((week) => (
|
|
145
|
+
<div key={dayKey(week[0] ?? month)} role="row" className="grid grid-cols-7">
|
|
146
|
+
{week.map((date) => {
|
|
147
|
+
const key = dayKey(date);
|
|
148
|
+
const list = byDay.get(key) ?? [];
|
|
149
|
+
const inMonth = sameMonth(date, month);
|
|
150
|
+
const isToday = sameDay(date, today);
|
|
151
|
+
const isSelected = sameDay(date, selected);
|
|
152
|
+
const extra = list.length - maxEventsPerDay;
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
key={key}
|
|
156
|
+
role="gridcell"
|
|
157
|
+
aria-selected={isSelected}
|
|
158
|
+
className="min-w-0 border-e border-b border-border/70 [&:nth-child(7)]:border-e-0"
|
|
159
|
+
>
|
|
160
|
+
<button
|
|
161
|
+
type="button"
|
|
162
|
+
data-date={key}
|
|
163
|
+
tabIndex={sameDay(date, tabStop) ? 0 : -1}
|
|
164
|
+
aria-label={`${formatFullDate(date, locale)}${list.length ? `, ${t('calendar.events', { count: list.length })}` : ''}`}
|
|
165
|
+
aria-current={isToday ? 'date' : undefined}
|
|
166
|
+
onClick={() => select(date)}
|
|
167
|
+
onKeyDown={(e) => onKeyDown(e, date)}
|
|
168
|
+
className={cn(
|
|
169
|
+
'flex h-full min-h-14 w-full flex-col items-stretch p-1.5 text-start transition-colors motion-reduce:transition-none sm:min-h-[92px] sm:p-2',
|
|
170
|
+
'hover:bg-accent/30 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-ring',
|
|
171
|
+
inMonth ? 'bg-card' : 'bg-secondary/20',
|
|
172
|
+
)}
|
|
173
|
+
>
|
|
174
|
+
<span className="flex items-center justify-between">
|
|
175
|
+
<span
|
|
176
|
+
className={cn(
|
|
177
|
+
'inline-flex size-6 items-center justify-center rounded-full text-[12px] font-medium tabular-nums',
|
|
178
|
+
isToday
|
|
179
|
+
? 'bg-primary font-semibold text-primary-foreground'
|
|
180
|
+
: isSelected
|
|
181
|
+
? 'bg-secondary text-foreground ring-1 ring-border'
|
|
182
|
+
: inMonth
|
|
183
|
+
? 'text-foreground'
|
|
184
|
+
: 'text-muted-foreground',
|
|
185
|
+
)}
|
|
186
|
+
>
|
|
187
|
+
{date.getDate()}
|
|
188
|
+
</span>
|
|
189
|
+
{isSelected && !isToday && <span aria-hidden className="size-1.5 rounded-full bg-primary" />}
|
|
190
|
+
</span>
|
|
191
|
+
{list.length > 0 && (
|
|
192
|
+
<span aria-hidden className="mt-1 flex gap-0.5 sm:hidden">
|
|
193
|
+
{list.slice(0, 3).map((e) => (
|
|
194
|
+
<span key={e.id} className={cn('size-1.5 rounded-full', TONE[kindOf(e, kinds).tone].dot)} />
|
|
195
|
+
))}
|
|
196
|
+
</span>
|
|
197
|
+
)}
|
|
198
|
+
<span aria-hidden className="mt-1.5 hidden space-y-1 sm:block">
|
|
199
|
+
{list.slice(0, maxEventsPerDay).map((e) => (
|
|
200
|
+
<span key={e.id} className="flex min-w-0 items-center gap-1.5">
|
|
201
|
+
<span className={cn('size-1.5 shrink-0 rounded-full', TONE[kindOf(e, kinds).tone].dot)} />
|
|
202
|
+
<span className="truncate text-[11px] text-foreground/80">{e.title}</span>
|
|
203
|
+
<span className="ms-auto hidden shrink-0 font-mono text-[10px] text-muted-foreground xl:block">
|
|
204
|
+
{formatTime(e.start, locale)}
|
|
205
|
+
</span>
|
|
206
|
+
</span>
|
|
207
|
+
))}
|
|
208
|
+
{extra > 0 && (
|
|
209
|
+
<span className="block ps-3 text-[10.5px] text-muted-foreground">
|
|
210
|
+
+ {t('common.more', { count: extra })}
|
|
211
|
+
</span>
|
|
212
|
+
)}
|
|
213
|
+
</span>
|
|
214
|
+
</button>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
})}
|
|
218
|
+
</div>
|
|
219
|
+
))}
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BlockMeta } from '../../meta';
|
|
2
|
+
|
|
3
|
+
export const meta: BlockMeta = {
|
|
4
|
+
name: 'Month calendar',
|
|
5
|
+
family: 'scheduling',
|
|
6
|
+
status: 'beta',
|
|
7
|
+
description:
|
|
8
|
+
'Monday-first month grid of scheduled work with per-day event lines, today/selected states, month navigation and full grid keyboard support.',
|
|
9
|
+
uses: ['Button', 'IconButton'],
|
|
10
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
4
|
+
import { TimeSlotPicker } from './TimeSlotPicker';
|
|
5
|
+
|
|
6
|
+
describe('TimeSlotPicker', () => {
|
|
7
|
+
it('renders a radio group with taken slots disabled', async () => {
|
|
8
|
+
const { container } = render(<TimeSlotPicker description="Wednesday, April 15" />);
|
|
9
|
+
expect(screen.getByRole('group', { name: 'Available times' })).toBeInTheDocument();
|
|
10
|
+
expect(screen.getAllByRole('radio')).toHaveLength(25);
|
|
11
|
+
expect(screen.getByRole('radio', { name: /^09:00/ })).toBeDisabled();
|
|
12
|
+
await expectNoAxeViolations(container);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('selects by click and by arrow keys', async () => {
|
|
16
|
+
const user = userEvent.setup();
|
|
17
|
+
const onValueChange = vi.fn();
|
|
18
|
+
render(<TimeSlotPicker onValueChange={onValueChange} />);
|
|
19
|
+
await user.click(screen.getByRole('radio', { name: '10:00' }));
|
|
20
|
+
expect(screen.getByRole('radio', { name: '10:00' })).toBeChecked();
|
|
21
|
+
expect(onValueChange).toHaveBeenLastCalledWith('10:00');
|
|
22
|
+
await user.keyboard('{ArrowRight}');
|
|
23
|
+
expect(screen.getByRole('radio', { name: '10:30' })).toBeChecked();
|
|
24
|
+
expect(onValueChange).toHaveBeenLastCalledWith('10:30');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useId, useState } from 'react';
|
|
2
|
+
import { cn, useI18n } from '@gntik-ai/ui';
|
|
3
|
+
import { sampleTimeSlots } from './fixtures';
|
|
4
|
+
|
|
5
|
+
export interface TimeSlot {
|
|
6
|
+
/** Submitted value, e.g. "09:30". */
|
|
7
|
+
value: string;
|
|
8
|
+
/** Visible label. Defaults to `value`. */
|
|
9
|
+
label?: string;
|
|
10
|
+
/** Taken slots render struck through and disabled. Default true. */
|
|
11
|
+
available?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TimeSlotPickerProps {
|
|
15
|
+
slots?: TimeSlot[];
|
|
16
|
+
/** Controlled value. */
|
|
17
|
+
value?: string | null;
|
|
18
|
+
/** Uncontrolled initial value. */
|
|
19
|
+
defaultValue?: string | null;
|
|
20
|
+
onValueChange?: (value: string) => void;
|
|
21
|
+
/** Group label (the fieldset legend). */
|
|
22
|
+
legend?: string;
|
|
23
|
+
/** Secondary line under the legend, e.g. the chosen date. */
|
|
24
|
+
description?: string;
|
|
25
|
+
/** Form field name. */
|
|
26
|
+
name?: string;
|
|
27
|
+
/** Slot columns from the `sm` breakpoint (two on small screens). */
|
|
28
|
+
columns?: 2 | 3 | 4 | 6;
|
|
29
|
+
/** Max height of the scrolling slot list in px. */
|
|
30
|
+
maxHeight?: number;
|
|
31
|
+
className?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const COLS: Record<NonNullable<TimeSlotPickerProps['columns']>, string> = {
|
|
35
|
+
2: 'sm:grid-cols-2',
|
|
36
|
+
3: 'sm:grid-cols-3',
|
|
37
|
+
4: 'sm:grid-cols-4',
|
|
38
|
+
6: 'sm:grid-cols-6',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Pick one time slot. Native radio semantics: Tab enters the group, arrow keys move and select,
|
|
43
|
+
* taken slots are disabled.
|
|
44
|
+
*/
|
|
45
|
+
export function TimeSlotPicker({
|
|
46
|
+
slots = sampleTimeSlots,
|
|
47
|
+
value,
|
|
48
|
+
defaultValue = null,
|
|
49
|
+
onValueChange,
|
|
50
|
+
legend: legendProp,
|
|
51
|
+
description,
|
|
52
|
+
name,
|
|
53
|
+
columns = 4,
|
|
54
|
+
maxHeight = 244,
|
|
55
|
+
className,
|
|
56
|
+
}: TimeSlotPickerProps) {
|
|
57
|
+
const { t } = useI18n();
|
|
58
|
+
const legend = legendProp ?? t('calendar.availableTimes');
|
|
59
|
+
const autoName = useId();
|
|
60
|
+
const descId = useId();
|
|
61
|
+
const [inner, setInner] = useState<string | null>(defaultValue);
|
|
62
|
+
const current = value !== undefined ? value : inner;
|
|
63
|
+
|
|
64
|
+
const choose = (next: string) => {
|
|
65
|
+
if (value === undefined) setInner(next);
|
|
66
|
+
onValueChange?.(next);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<fieldset aria-describedby={description ? descId : undefined} className={cn('min-w-0', className)}>
|
|
71
|
+
<legend className="text-[12.5px] font-medium text-foreground">{legend}</legend>
|
|
72
|
+
{description && (
|
|
73
|
+
<p id={descId} className="mt-0.5 text-[12px] text-muted-foreground">
|
|
74
|
+
{description}
|
|
75
|
+
</p>
|
|
76
|
+
)}
|
|
77
|
+
<div className="mt-2.5 overflow-y-auto p-0.5" style={{ maxHeight }}>
|
|
78
|
+
<div className={cn('grid grid-cols-2 gap-1.5', COLS[columns])}>
|
|
79
|
+
{slots.map((slot) => {
|
|
80
|
+
const available = slot.available !== false;
|
|
81
|
+
return (
|
|
82
|
+
<label
|
|
83
|
+
key={slot.value}
|
|
84
|
+
className={cn('relative block', available ? 'cursor-pointer' : 'cursor-not-allowed')}
|
|
85
|
+
>
|
|
86
|
+
<input
|
|
87
|
+
type="radio"
|
|
88
|
+
name={name ?? autoName}
|
|
89
|
+
value={slot.value}
|
|
90
|
+
checked={current === slot.value}
|
|
91
|
+
disabled={!available}
|
|
92
|
+
onChange={() => choose(slot.value)}
|
|
93
|
+
className="peer sr-only"
|
|
94
|
+
/>
|
|
95
|
+
<span
|
|
96
|
+
className={cn(
|
|
97
|
+
'flex h-8 items-center justify-center rounded-md border font-mono text-[12px] font-medium tabular-nums transition-colors motion-reduce:transition-none',
|
|
98
|
+
'peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-focus-ring',
|
|
99
|
+
'peer-checked:border-primary peer-checked:bg-primary peer-checked:text-primary-foreground peer-checked:shadow-sm',
|
|
100
|
+
available
|
|
101
|
+
? 'border-border bg-background text-foreground hover:border-muted-foreground/40 hover:bg-secondary/60'
|
|
102
|
+
: 'border-border/50 bg-secondary/20 text-muted-foreground line-through',
|
|
103
|
+
)}
|
|
104
|
+
>
|
|
105
|
+
{slot.label ?? slot.value}
|
|
106
|
+
{!available && <span className="sr-only"> {t('calendar.unavailable')}</span>}
|
|
107
|
+
</span>
|
|
108
|
+
</label>
|
|
109
|
+
);
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</fieldset>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BlockMeta } from '../../meta';
|
|
2
|
+
|
|
3
|
+
export const meta: BlockMeta = {
|
|
4
|
+
name: 'Time slot picker',
|
|
5
|
+
family: 'scheduling',
|
|
6
|
+
status: 'beta',
|
|
7
|
+
description:
|
|
8
|
+
'Grid of selectable time slots with native radio semantics (arrow keys, form name), taken slots struck through and disabled, controlled or uncontrolled.',
|
|
9
|
+
uses: [],
|
|
10
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TimeSlot } from './TimeSlotPicker';
|
|
2
|
+
|
|
3
|
+
const busy = new Set(['09:00', '09:30', '12:00', '14:30', '15:00', '18:30']);
|
|
4
|
+
|
|
5
|
+
/** Half-hour slots from 09:00 to 21:00 with a few already taken. */
|
|
6
|
+
export const sampleTimeSlots: TimeSlot[] = Array.from({ length: 25 }, (_, i) => {
|
|
7
|
+
const minutes = 9 * 60 + i * 30;
|
|
8
|
+
const value = `${String(Math.floor(minutes / 60)).padStart(2, '0')}:${String(minutes % 60).padStart(2, '0')}`;
|
|
9
|
+
return { value, available: !busy.has(value) };
|
|
10
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { render, screen, within } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
4
|
+
import { WeekCalendar } from './WeekCalendar';
|
|
5
|
+
|
|
6
|
+
describe('WeekCalendar', () => {
|
|
7
|
+
it('renders the sample week with its events per day', async () => {
|
|
8
|
+
const { container } = render(<WeekCalendar />);
|
|
9
|
+
expect(screen.getByRole('heading', { name: 'Apr 13 – 19, 2026' })).toBeInTheDocument();
|
|
10
|
+
const wednesday = screen.getByRole('list', { name: 'Wednesday, April 15' });
|
|
11
|
+
expect(within(wednesday).getAllByRole('listitem')).toHaveLength(9);
|
|
12
|
+
await expectNoAxeViolations(container);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('changes week and reports event clicks', async () => {
|
|
16
|
+
const user = userEvent.setup();
|
|
17
|
+
const onEventClick = vi.fn();
|
|
18
|
+
const onWeekChange = vi.fn();
|
|
19
|
+
render(<WeekCalendar onEventClick={onEventClick} onWeekChange={onWeekChange} />);
|
|
20
|
+
await user.click(screen.getByRole('button', { name: 'Checkout hotfix, 09:00–10:00, eu-west-1' }));
|
|
21
|
+
expect(onEventClick).toHaveBeenCalledWith(expect.objectContaining({ title: 'Checkout hotfix' }));
|
|
22
|
+
await user.click(screen.getByRole('button', { name: 'Next week' }));
|
|
23
|
+
expect(onWeekChange).toHaveBeenCalledWith(new Date(2026, 3, 20));
|
|
24
|
+
expect(screen.getByRole('heading', { name: 'Apr 20 – 26, 2026' })).toBeInTheDocument();
|
|
25
|
+
await expectNoAxeViolations(document.body);
|
|
26
|
+
});
|
|
27
|
+
});
|