@gntik-ai/blocks 0.10.0 → 0.12.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 +1761 -1231
- package/dist/index.js +3280 -1088
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/ai/PromptEditor/PromptEditor.tsx +2 -2
- package/src/ai/PromptEditor/examples/controlled-variables.tsx +1 -1
- package/src/ai/TraceWaterfall/TraceWaterfall.tsx +2 -2
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.labels.test.tsx +179 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.test.tsx +6 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +63 -25
- package/src/auth/ForgotPasswordForm/block.meta.ts +22 -1
- package/src/auth/ForgotPasswordForm/examples/Labels.tsx +29 -0
- package/src/auth/ForgotPasswordForm/examples/LargeFields.tsx +6 -0
- package/src/auth/MfaChallenge/MfaChallenge.labels.test.tsx +139 -0
- package/src/auth/MfaChallenge/MfaChallenge.test.tsx +9 -0
- package/src/auth/MfaChallenge/MfaChallenge.tsx +74 -25
- package/src/auth/MfaChallenge/block.meta.ts +29 -1
- package/src/auth/MfaChallenge/examples/Labels.tsx +28 -0
- package/src/auth/MfaChallenge/examples/LargeFields.tsx +6 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.labels.test.tsx +104 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.test.tsx +7 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +47 -18
- package/src/auth/ResetPasswordForm/block.meta.ts +17 -1
- package/src/auth/ResetPasswordForm/examples/Labels.tsx +28 -0
- package/src/auth/ResetPasswordForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SignInForm/SignInForm.labels.test.tsx +137 -0
- package/src/auth/SignInForm/SignInForm.test.tsx +7 -0
- package/src/auth/SignInForm/SignInForm.tsx +48 -17
- package/src/auth/SignInForm/block.meta.ts +22 -1
- package/src/auth/SignInForm/examples/Labels.tsx +29 -0
- package/src/auth/SignInForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SignUpForm/SignUpForm.labels.test.tsx +217 -0
- package/src/auth/SignUpForm/SignUpForm.test.tsx +22 -0
- package/src/auth/SignUpForm/SignUpForm.tsx +72 -27
- package/src/auth/SignUpForm/block.meta.ts +27 -1
- package/src/auth/SignUpForm/examples/Labels.tsx +29 -0
- package/src/auth/SignUpForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SsoButtons/SsoButtons.labels.test.tsx +30 -0
- package/src/auth/SsoButtons/SsoButtons.tsx +10 -2
- package/src/auth/SsoButtons/block.meta.ts +8 -1
- package/src/auth/SsoButtons/examples/Labels.tsx +24 -0
- package/src/auth/__snapshots__/field-size.test.tsx.snap +11 -0
- package/src/auth/field-size.test.tsx +21 -0
- package/src/auth/large-examples.test.tsx +30 -0
- package/src/auth/shared.i18n.test.tsx +71 -0
- package/src/auth/shared.tsx +55 -13
- package/src/billing/PaymentMethodCard/PaymentMethodCard.tsx +1 -1
- package/src/billing/PlanCard/PlanCard.baseline.test.tsx +3 -2
- package/src/billing/PlanCard/__snapshots__/PlanCard.baseline.test.tsx.snap +2 -2
- package/src/billing/PlanDefinitionCard/examples/Compact.tsx +1 -4
- package/src/billing/PlanDefinitionCard/examples/Full.tsx +1 -4
- package/src/builders/CodePanel/CodePanel.tsx +2 -2
- package/src/builders/FlowBuilder/FlowBuilder.tsx +4 -19
- package/src/builders/FlowBuilder/parts.tsx +4 -4
- package/src/builders/LogViewer/LogViewer.follow.test.tsx +29 -0
- package/src/builders/LogViewer/LogViewer.levels.test.tsx +49 -0
- package/src/builders/LogViewer/LogViewer.test.tsx +24 -0
- package/src/builders/LogViewer/LogViewer.tsx +96 -28
- package/src/builders/LogViewer/LogViewer.wrap.test.tsx +181 -0
- package/src/builders/LogViewer/block.meta.ts +7 -1
- package/src/builders/LogViewer/examples/Spanish.tsx +2 -1
- package/src/builders/LogViewer/examples/Wrap.tsx +62 -0
- package/src/builders/LogViewer/use-wrapped-log-rows.ts +42 -0
- package/src/data-display/ActivityFeed/ActivityFeed.tsx +1 -1
- package/src/data-display/ChartCard/ChartCard.tsx +2 -2
- package/src/data-display/ChartCard/examples/ContainerPanel.tsx +16 -0
- package/src/data-display/CommentThread/CommentThread.test.tsx +70 -1
- package/src/data-display/CommentThread/CommentThread.tsx +22 -6
- package/src/data-display/CommentThread/block.meta.ts +1 -1
- package/src/data-display/CommentThread/examples/RenderedBody.tsx +20 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.options.test.tsx +64 -0
- package/src/data-display/DescriptionListCard/DescriptionListCard.test.tsx +24 -1
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +52 -37
- package/src/data-display/DescriptionListCard/block.meta.ts +2 -1
- package/src/data-display/DescriptionListCard/examples/Spanish.tsx +9 -1
- package/src/data-display/KpiRow/KpiRow.doc.ts +14 -0
- package/src/data-display/KpiRow/KpiRow.test.tsx +11 -0
- package/src/data-display/KpiRow/KpiRow.tsx +72 -55
- package/src/data-display/KpiRow/examples/ContainerPanel.tsx +47 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.doc.ts +19 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.test.tsx +13 -0
- package/src/data-display/ResourceCardGrid/ResourceCardGrid.tsx +49 -40
- package/src/data-display/ResourceCardGrid/examples/ContainerPanel.tsx +18 -0
- package/src/data-display/StatusTimeline/StatusTimeline.tsx +1 -1
- package/src/feedback/EmptyStates/EmptyStates.test.tsx +42 -0
- package/src/feedback/EmptyStates/EmptyStates.tsx +37 -17
- package/src/feedback/EmptyStates/NoAccessEmpty.options.test.tsx +38 -0
- package/src/feedback/EmptyStates/block.meta.ts +1 -1
- package/src/feedback/EmptyStates/examples/HiddenAction.tsx +13 -0
- package/src/feedback/EmptyStates/examples/Spanish.tsx +7 -0
- package/src/feedback/ErrorPanel/ErrorPanel.tsx +13 -15
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.labels.test.tsx +115 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.lifecycle.test.tsx +123 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +153 -122
- package/src/forms/CreateApiKeyDialog/block.meta.ts +34 -2
- package/src/forms/CreateApiKeyDialog/examples/Labels.tsx +29 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.labels.test.tsx +165 -0
- package/src/forms/CredentialDisclosureDialog/CredentialDisclosureDialog.tsx +31 -8
- package/src/forms/CredentialDisclosureDialog/SecretCopy.tsx +16 -8
- package/src/forms/CredentialDisclosureDialog/block.meta.ts +19 -1
- package/src/forms/CredentialDisclosureDialog/examples/Labels.tsx +38 -0
- package/src/forms/DangerZone/ConfirmDestructiveDialog.tsx +17 -3
- package/src/forms/DangerZone/DangerZone.labels.test.tsx +87 -0
- package/src/forms/DangerZone/DangerZone.tsx +20 -5
- package/src/forms/DangerZone/block.meta.ts +10 -1
- package/src/forms/DangerZone/examples/Labels.tsx +29 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.labels.test.tsx +52 -0
- package/src/forms/DateRangeFilter/DateRangeFilter.tsx +11 -3
- package/src/forms/DateRangeFilter/block.meta.ts +8 -1
- package/src/forms/DateRangeFilter/examples/Labels.tsx +28 -0
- package/src/forms/DialogWizard/DialogWizard.labels.test.tsx +37 -0
- package/src/forms/DialogWizard/DialogWizard.tsx +13 -2
- package/src/forms/DialogWizard/block.meta.ts +7 -1
- package/src/forms/DialogWizard/examples/Labels.tsx +39 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.controlled.test.tsx +482 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.drag.test.tsx +60 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.labels.test.tsx +126 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.lifecycle.test.tsx +165 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.tsx +336 -75
- package/src/forms/FileUploadPanel/block.meta.ts +26 -1
- package/src/forms/FileUploadPanel/examples/AutoCancel.tsx +38 -0
- package/src/forms/FileUploadPanel/examples/Labels.tsx +29 -0
- package/src/forms/FileUploadPanel/examples/ManualForm.tsx +36 -0
- package/src/forms/FileUploadPanel/fixtures.ts +31 -16
- package/src/forms/FileUploadPanel/simulate-upload.test.ts +24 -0
- package/src/forms/FormSection/FormSection.labels.test.tsx +37 -0
- package/src/forms/FormSection/FormSection.test.tsx +11 -0
- package/src/forms/FormSection/FormSection.tsx +34 -25
- package/src/forms/FormSection/block.meta.ts +7 -1
- package/src/forms/FormSection/examples/ContainerPanel.tsx +16 -0
- package/src/forms/FormSection/examples/Labels.tsx +27 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.labels.test.tsx +87 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.lifecycle.test.tsx +80 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +121 -105
- package/src/forms/InviteMembersDialog/block.meta.ts +21 -2
- package/src/forms/InviteMembersDialog/examples/Labels.tsx +28 -0
- package/src/forms/SettingsRow/SettingsRow.labels.test.tsx +33 -0
- package/src/forms/SettingsRow/SettingsRow.tsx +14 -3
- package/src/forms/SettingsRow/block.meta.ts +7 -1
- package/src/forms/SettingsRow/examples/Labels.tsx +27 -0
- package/src/forms/ValidationSummary/ValidationSummary.labels.test.tsx +47 -0
- package/src/forms/ValidationSummary/ValidationSummary.tsx +10 -7
- package/src/forms/ValidationSummary/block.meta.ts +6 -1
- package/src/forms/ValidationSummary/examples/Labels.tsx +24 -0
- package/src/forms/index.ts +5 -1
- package/src/forms/translated-content.tsx +12 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useTableData.integration.test.tsx +89 -0
- package/src/hooks/useTableData.test.tsx +613 -0
- package/src/hooks/useTableData.ts +377 -0
- package/src/index.ts +1 -0
- package/src/marketing/ComparisonTable/ComparisonTable.tsx +2 -2
- package/src/marketing/FeatureGrid/FeatureGrid.tsx +1 -1
- package/src/marketing/LogoCloud/LogoCloud.doc.ts +13 -0
- package/src/marketing/LogoCloud/LogoCloud.test.tsx +155 -0
- package/src/marketing/LogoCloud/LogoCloud.tsx +89 -0
- package/src/marketing/LogoCloud/block.meta.ts +10 -0
- package/src/marketing/LogoCloud/examples/CaptionStart.tsx +6 -0
- package/src/marketing/LogoCloud/examples/Custom.tsx +25 -0
- package/src/marketing/LogoCloud/examples/Empty.tsx +6 -0
- package/src/marketing/LogoCloud/examples/Grid.tsx +13 -0
- package/src/marketing/LogoCloud/examples/Row.tsx +6 -0
- package/src/marketing/LogoCloud/examples/UnderHero.tsx +13 -0
- package/src/marketing/LogoCloud/fixtures.ts +23 -0
- package/src/marketing/PricingTable/PricingTable.tsx +1 -1
- package/src/marketing/SiteFooter/SiteFooter.doc.ts +18 -0
- package/src/marketing/SiteFooter/SiteFooter.test.tsx +236 -0
- package/src/marketing/SiteFooter/SiteFooter.tsx +160 -0
- package/src/marketing/SiteFooter/block.meta.ts +10 -0
- package/src/marketing/SiteFooter/examples/Centered.tsx +15 -0
- package/src/marketing/SiteFooter/examples/Columns.tsx +15 -0
- package/src/marketing/SiteFooter/examples/Custom.tsx +35 -0
- package/src/marketing/SiteFooter/examples/Empty.tsx +6 -0
- package/src/marketing/SiteFooter/examples/Simple.tsx +14 -0
- package/src/marketing/SiteFooter/fixtures.ts +36 -0
- package/src/marketing/index.ts +6 -0
- package/src/page-chrome/PageHeader/EditableTitle.test.tsx +26 -0
- package/src/page-chrome/PageHeader/PageHeader.options.test.tsx +34 -0
- package/src/page-chrome/PageHeader/PageHeader.tsx +11 -5
- package/src/page-chrome/PageHeader/block.meta.ts +1 -1
- package/src/page-chrome/PageHeader/examples/ContainerPanel.tsx +16 -0
- package/src/page-chrome/PageHeader/examples/EditableTitle.tsx +23 -0
- package/src/page-chrome/PageHeader/examples/Spanish.tsx +11 -0
- package/src/page-chrome/StickyActionBar/StickyActionBar.tsx +1 -1
- package/src/scheduling/AgendaList/AgendaList.tsx +39 -15
- package/src/scheduling/AgendaList/AgendaListZone.test.tsx +38 -0
- package/src/scheduling/AgendaList/block.meta.ts +1 -1
- package/src/scheduling/AgendaList/examples/TimeZone.tsx +28 -0
- package/src/scheduling/MonthCalendar/MonthCalendar.tsx +51 -40
- package/src/scheduling/MonthCalendar/MonthCalendarZone.test.tsx +44 -0
- package/src/scheduling/MonthCalendar/block.meta.ts +1 -1
- package/src/scheduling/MonthCalendar/examples/TimeZone.tsx +28 -0
- package/src/scheduling/WeekCalendar/WeekCalendar.tsx +37 -28
- package/src/scheduling/WeekCalendar/WeekCalendarZone.test.tsx +41 -0
- package/src/scheduling/WeekCalendar/block.meta.ts +1 -1
- package/src/scheduling/WeekCalendar/examples/TimeZone.tsx +28 -0
- package/src/scheduling/shared/CalendarHeader.tsx +26 -1
- package/src/scheduling/shared/dates.ts +102 -58
- package/src/scheduling/shared/events.ts +2 -2
- package/src/shell/AppSidebar/AppSidebar.context.test.tsx +175 -0
- package/src/shell/AppSidebar/AppSidebar.doc.ts +29 -0
- package/src/shell/AppSidebar/AppSidebar.tsx +97 -25
- package/src/shell/AppSidebar/block.meta.ts +1 -1
- package/src/shell/GlobalSearch/GlobalSearch.test.tsx +1 -0
- package/src/shell/GlobalSearch/GlobalSearch.tsx +1 -1
- package/src/tables/DataTable/DataTable.cross-page-selection.test.tsx +322 -0
- package/src/tables/DataTable/DataTable.cursor-example.test.tsx +67 -0
- package/src/tables/DataTable/DataTable.export.test.tsx +511 -0
- package/src/tables/DataTable/DataTable.inline-edit-focus.test.tsx +32 -0
- package/src/tables/DataTable/DataTable.labels.test.tsx +74 -0
- package/src/tables/DataTable/DataTable.layout.test.tsx +6 -5
- package/src/tables/DataTable/DataTable.link-actions.test.tsx +18 -0
- package/src/tables/DataTable/DataTable.server-pagination.test.tsx +329 -15
- package/src/tables/DataTable/DataTable.single-select.test.tsx +47 -7
- package/src/tables/DataTable/DataTable.test.tsx +140 -1
- package/src/tables/DataTable/DataTable.tsx +241 -80
- package/src/tables/DataTable/block.meta.ts +31 -3
- package/src/tables/DataTable/column-sizing.ts +2 -2
- package/src/tables/DataTable/data-table-props.ts +43 -6
- package/src/tables/DataTable/data-table-row.tsx +9 -5
- package/src/tables/DataTable/data-table-utils.ts +6 -0
- package/src/tables/DataTable/editable-cell.tsx +20 -79
- package/src/tables/DataTable/examples/client-selection.tsx +33 -0
- package/src/tables/DataTable/examples/csv-export.tsx +74 -0
- package/src/tables/DataTable/examples/cursor-load-more.tsx +87 -0
- package/src/tables/DataTable/examples/paginated-single-selection.tsx +46 -0
- package/src/tables/DataTable/examples/server-pagination.tsx +91 -44
- package/src/tables/DataTable/export-menu.tsx +58 -0
- package/src/tables/DataTable/header-cell.tsx +1 -1
- package/src/tables/DataTable/labels.ts +11 -0
- package/src/tables/DataTable/resize-handle.tsx +2 -2
- package/src/tables/DataTable/selection-strip.tsx +31 -0
- package/src/tables/DataTable/single-selection.tsx +0 -7
- package/src/tables/DataTable/use-multiple-selection.ts +86 -0
- package/src/tables/DataTable/use-table-export.ts +117 -0
- package/src/tables/FilterBar/FilterBar.test.tsx +12 -0
- package/src/tables/FilterBar/FilterBar.tsx +5 -7
- package/src/team/ProfileHeader/ProfileHeader.picker.test.tsx +34 -0
- package/src/team/ProfileHeader/ProfileHeader.test.tsx +2 -2
- package/src/team/ProfileHeader/ProfileHeader.tsx +17 -24
- package/src/team/ProfileHeader/block.meta.ts +1 -1
- package/src/test/OptInDefaults.test.tsx +36 -0
- package/src/test/clipboard-fallback.test.tsx +49 -0
- package/src/test/copy-examples.test.tsx +29 -0
- package/src/test/copy-feedback.test.tsx +166 -0
- package/src/test/fixtures/opt-in-defaults.json +10 -0
- package/src/test/without-forced-colors.test.ts +44 -0
- package/src/test/without-forced-colors.ts +14 -0
|
@@ -23,14 +23,25 @@ export interface KpiRowProps {
|
|
|
23
23
|
/** Accessible name of the list. */
|
|
24
24
|
label?: string;
|
|
25
25
|
className?: string;
|
|
26
|
+
/** Styles the container wrapper, including placement in a parent grid. */
|
|
27
|
+
containerClassName?: string;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const COLS: Record<number, string> = {
|
|
29
|
-
1: '
|
|
30
|
-
2: '
|
|
31
|
-
3: '
|
|
32
|
-
4: '
|
|
33
|
-
5: '
|
|
31
|
+
1: '@4xl:grid-cols-1',
|
|
32
|
+
2: '@4xl:grid-cols-2',
|
|
33
|
+
3: '@4xl:grid-cols-3',
|
|
34
|
+
4: '@4xl:grid-cols-4',
|
|
35
|
+
5: '@4xl:grid-cols-5',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Only internal edges: no border on a row's last tile or on the list's last tile.
|
|
39
|
+
const STRIP_DIVIDERS: Record<number, string> = {
|
|
40
|
+
1: '',
|
|
41
|
+
2: '@4xl:[&>div:not(:nth-child(2n)):not(:last-child)]:border-e',
|
|
42
|
+
3: '@4xl:[&>div:not(:nth-child(3n)):not(:last-child)]:border-e',
|
|
43
|
+
4: '@4xl:[&>div:not(:nth-child(4n)):not(:last-child)]:border-e',
|
|
44
|
+
5: '@4xl:[&>div:not(:nth-child(5n)):not(:last-child)]:border-e',
|
|
34
45
|
};
|
|
35
46
|
|
|
36
47
|
/**
|
|
@@ -43,59 +54,65 @@ export function KpiRow({
|
|
|
43
54
|
showTrends = true,
|
|
44
55
|
label = 'Key metrics',
|
|
45
56
|
className,
|
|
57
|
+
containerClassName,
|
|
46
58
|
}: KpiRowProps) {
|
|
47
59
|
const strip = variant === 'strip';
|
|
48
|
-
const cols = COLS[Math.min(items.length, 5)] ?? '
|
|
60
|
+
const cols = COLS[Math.min(items.length, 5)] ?? '@4xl:grid-cols-4';
|
|
49
61
|
return (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{showTrends && item.trend && item.trend.length > 1 && (
|
|
85
|
-
<dd className="mt-3">
|
|
86
|
-
<Sparkline
|
|
87
|
-
data={item.trend}
|
|
88
|
-
label={item.label}
|
|
89
|
-
area
|
|
90
|
-
tone={item.trendTone ?? 'primary'}
|
|
91
|
-
width={240}
|
|
92
|
-
height={40}
|
|
93
|
-
className="block h-auto w-full"
|
|
94
|
-
/>
|
|
62
|
+
<div className={cn('@container w-full min-w-0', containerClassName)}>
|
|
63
|
+
<dl
|
|
64
|
+
aria-label={label}
|
|
65
|
+
className={cn(
|
|
66
|
+
'grid grid-cols-1 @lg:grid-cols-2',
|
|
67
|
+
cols,
|
|
68
|
+
strip
|
|
69
|
+
? 'overflow-hidden rounded-xl border border-border bg-card shadow-sm [&>div]:border-border @max-lg:[&>div:not(:last-child)]:border-b @lg:@max-4xl:[&>div:nth-child(odd):not(:last-child)]:border-e'
|
|
70
|
+
: 'gap-4',
|
|
71
|
+
strip && (STRIP_DIVIDERS[Math.min(items.length, 5)] ?? STRIP_DIVIDERS[4]),
|
|
72
|
+
className,
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
{items.map((item) => (
|
|
76
|
+
<div
|
|
77
|
+
key={item.id}
|
|
78
|
+
className={cn(
|
|
79
|
+
'flex min-w-0 flex-col',
|
|
80
|
+
strip ? 'px-5 py-4' : 'rounded-xl border border-border bg-card p-5 shadow-sm',
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
<dt className={cn('truncate font-medium text-muted-foreground', strip ? 'text-[12px]' : 'text-[13px]')}>
|
|
84
|
+
{item.label}
|
|
85
|
+
</dt>
|
|
86
|
+
<dd className="mt-2 flex flex-wrap items-baseline gap-x-2 gap-y-1">
|
|
87
|
+
<span
|
|
88
|
+
className={cn(
|
|
89
|
+
'font-semibold tracking-tight text-foreground tabular-nums',
|
|
90
|
+
strip ? 'text-[22px]' : 'text-[26px]',
|
|
91
|
+
)}
|
|
92
|
+
>
|
|
93
|
+
{item.value}
|
|
94
|
+
</span>
|
|
95
|
+
{item.delta && <TrendDelta {...item.delta} />}
|
|
95
96
|
</dd>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
{item.delta?.note && !strip && (
|
|
98
|
+
<dd className="mt-1 text-[12px] text-muted-foreground">{item.delta.note}</dd>
|
|
99
|
+
)}
|
|
100
|
+
{showTrends && item.trend && item.trend.length > 1 && (
|
|
101
|
+
<dd className="mt-3">
|
|
102
|
+
<Sparkline
|
|
103
|
+
data={item.trend}
|
|
104
|
+
label={item.label}
|
|
105
|
+
area
|
|
106
|
+
tone={item.trendTone ?? 'primary'}
|
|
107
|
+
width={240}
|
|
108
|
+
height={40}
|
|
109
|
+
className="block h-auto w-full"
|
|
110
|
+
/>
|
|
111
|
+
</dd>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
))}
|
|
115
|
+
</dl>
|
|
116
|
+
</div>
|
|
100
117
|
);
|
|
101
118
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { InspectorLayout, Page, SidebarLayout } from '@gntik-ai/ui';
|
|
2
|
+
import { ResourceCardGrid } from '../../ResourceCardGrid/ResourceCardGrid';
|
|
3
|
+
import { ChartCard } from '../../ChartCard/ChartCard';
|
|
4
|
+
import { FormSection } from '../../../forms/FormSection/FormSection';
|
|
5
|
+
import { PageHeader } from '../../../page-chrome/PageHeader/PageHeader';
|
|
6
|
+
import { KpiRow } from '../KpiRow';
|
|
7
|
+
|
|
8
|
+
export default function ContainerPanel() {
|
|
9
|
+
return (
|
|
10
|
+
<div data-container-example className="h-[640px] overflow-hidden rounded-lg border border-border">
|
|
11
|
+
<InspectorLayout
|
|
12
|
+
panelTitle="Properties"
|
|
13
|
+
dockedQuery="(min-width: 0px)"
|
|
14
|
+
panel={<KpiRow variant="strip" showTrends={false} />}
|
|
15
|
+
>
|
|
16
|
+
<div className="grid gap-6 overflow-auto p-4">
|
|
17
|
+
<div data-container-slot="cards" className="flex min-w-0">
|
|
18
|
+
<KpiRow className="gap-6" containerClassName="col-span-2" />
|
|
19
|
+
</div>
|
|
20
|
+
<div data-container-slot="strip" className="flex min-w-0">
|
|
21
|
+
<KpiRow variant="strip" showTrends={false} />
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</InspectorLayout>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The default page frame also demonstrates the thresholds without a narrow panel.
|
|
30
|
+
export function StandardFrame() {
|
|
31
|
+
return (
|
|
32
|
+
<div className="h-[900px]">
|
|
33
|
+
<SidebarLayout sidebar={null}>
|
|
34
|
+
<Page>
|
|
35
|
+
<div data-standard-frame className="grid min-w-0 gap-6">
|
|
36
|
+
<PageHeader />
|
|
37
|
+
<KpiRow />
|
|
38
|
+
<ResourceCardGrid />
|
|
39
|
+
<ResourceCardGrid columns={4} />
|
|
40
|
+
<FormSection />
|
|
41
|
+
<ChartCard />
|
|
42
|
+
</div>
|
|
43
|
+
</Page>
|
|
44
|
+
</SidebarLayout>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentDoc } from '@gntik-ai/ui';
|
|
2
|
+
import { meta } from './block.meta';
|
|
3
|
+
|
|
4
|
+
export const doc: ComponentDoc = {
|
|
5
|
+
name: 'ResourceCardGrid',
|
|
6
|
+
group: 'Display',
|
|
7
|
+
status: 'beta',
|
|
8
|
+
description: meta.description,
|
|
9
|
+
primitive: 'Named list of cards with Base UI action menus',
|
|
10
|
+
pattern:
|
|
11
|
+
'Cards reflow by container width up to the columns cap. className styles the list; containerClassName styles its wrapper for placement and visibility.',
|
|
12
|
+
keyboard: [
|
|
13
|
+
['Tab', 'Move between card action menu triggers.'],
|
|
14
|
+
['Enter / Space', 'Open the focused action menu.'],
|
|
15
|
+
['Arrow keys', 'Move between actions in the open menu.'],
|
|
16
|
+
['Escape', 'Close the menu and return focus to its trigger.'],
|
|
17
|
+
],
|
|
18
|
+
tokens: ['card', 'border', 'foreground', 'muted-foreground', 'secondary'],
|
|
19
|
+
};
|
|
@@ -4,6 +4,19 @@ import { expectNoAxeViolations } from '../../test/a11y';
|
|
|
4
4
|
import { ResourceCardGrid } from './ResourceCardGrid';
|
|
5
5
|
|
|
6
6
|
describe('ResourceCardGrid', () => {
|
|
7
|
+
it('keeps list semantics and styling separate from wrapper placement', () => {
|
|
8
|
+
const { container } = render(
|
|
9
|
+
<ResourceCardGrid label="Services" className="gap-6" containerClassName="col-span-2" />,
|
|
10
|
+
);
|
|
11
|
+
const list = screen.getByRole('list', { name: 'Services' });
|
|
12
|
+
expect(list.tagName).toBe('UL');
|
|
13
|
+
expect(list).toHaveClass('gap-6');
|
|
14
|
+
expect(list).not.toHaveClass('col-span-2');
|
|
15
|
+
expect(list.parentElement).toBe(container.firstElementChild);
|
|
16
|
+
expect(list.parentElement).toHaveClass('col-span-2');
|
|
17
|
+
expect(list.parentElement).not.toHaveClass('gap-6');
|
|
18
|
+
});
|
|
19
|
+
|
|
7
20
|
it('renders one card per resource', async () => {
|
|
8
21
|
const { container } = render(<ResourceCardGrid />);
|
|
9
22
|
expect(screen.getByRole('list', { name: 'Resources' })).toBeInTheDocument();
|
|
@@ -26,14 +26,20 @@ export interface ResourceCardGridProps {
|
|
|
26
26
|
onAction?: (action: ResourceAction, item: ResourceCard) => void;
|
|
27
27
|
/** Replaces the default menu entirely. Return an empty array to hide the menu. */
|
|
28
28
|
getActions?: (item: ResourceCard) => Array<MoreMenuAction | 'separator'>;
|
|
29
|
-
/**
|
|
29
|
+
/** Maximum columns, chosen from this block's container width. */
|
|
30
30
|
columns?: 2 | 3 | 4;
|
|
31
31
|
/** Heading level of each card's name, to fit the page outline (default h3). */
|
|
32
32
|
titleAs?: 'h2' | 'h3' | 'h4';
|
|
33
33
|
className?: string;
|
|
34
|
+
/** Styles the container wrapper, including placement in a parent grid. */
|
|
35
|
+
containerClassName?: string;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
const COLS = {
|
|
38
|
+
const COLS = {
|
|
39
|
+
2: '@xl:grid-cols-2',
|
|
40
|
+
3: '@xl:grid-cols-2 @4xl:grid-cols-3',
|
|
41
|
+
4: '@xl:grid-cols-2 @3xl:grid-cols-3 @4xl:grid-cols-4',
|
|
42
|
+
} as const;
|
|
37
43
|
|
|
38
44
|
/** Responsive grid of resource cards: icon or avatar, name, status, meta figures and a row-actions MoreMenu. */
|
|
39
45
|
export function ResourceCardGrid({
|
|
@@ -44,6 +50,7 @@ export function ResourceCardGrid({
|
|
|
44
50
|
columns = 3,
|
|
45
51
|
titleAs: TitleTag = 'h3',
|
|
46
52
|
className,
|
|
53
|
+
containerClassName,
|
|
47
54
|
}: ResourceCardGridProps) {
|
|
48
55
|
const defaults = (item: ResourceCard): Array<MoreMenuAction | 'separator'> => [
|
|
49
56
|
{ label: 'Open', icon: ExternalLink, onSelect: () => onAction?.('open', item) },
|
|
@@ -53,46 +60,48 @@ export function ResourceCardGrid({
|
|
|
53
60
|
{ label: 'Delete', icon: Trash2, destructive: true, onSelect: () => onAction?.('delete', item) },
|
|
54
61
|
];
|
|
55
62
|
return (
|
|
56
|
-
<
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
<div className={cn('@container w-full min-w-0', containerClassName)}>
|
|
64
|
+
<ul aria-label={label} className={cn('grid grid-cols-1 gap-4', COLS[columns], className)}>
|
|
65
|
+
{items.map((item) => {
|
|
66
|
+
const actions = getActions ? getActions(item) : defaults(item);
|
|
67
|
+
const IconCmp = item.icon;
|
|
68
|
+
return (
|
|
69
|
+
<li key={item.id} className="flex min-w-0 flex-col rounded-xl border border-border bg-card p-5 shadow-sm">
|
|
70
|
+
<div className="flex items-start justify-between gap-3">
|
|
71
|
+
{item.avatar ? (
|
|
72
|
+
<Avatar name={item.avatar.name} src={item.avatar.src} size="md" shape="rounded" />
|
|
73
|
+
) : (
|
|
74
|
+
<span className="inline-flex size-10 shrink-0 items-center justify-center rounded-lg bg-secondary text-muted-foreground">
|
|
75
|
+
{IconCmp && <IconCmp size={20} aria-hidden />}
|
|
76
|
+
</span>
|
|
77
|
+
)}
|
|
78
|
+
<div className="flex items-center gap-2">
|
|
79
|
+
{item.status && <StatusTag status={item.status} />}
|
|
80
|
+
{actions.length > 0 && (
|
|
81
|
+
<MoreMenu items={actions} label={`Actions for ${item.name}`} variant="ghost" size="sm" />
|
|
82
|
+
)}
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
<div className="mt-4 min-w-0">
|
|
86
|
+
<TitleTag className="truncate text-[14px] font-semibold text-foreground">{item.name}</TitleTag>
|
|
87
|
+
{item.description && (
|
|
88
|
+
<p className="mt-0.5 truncate text-[12.5px] text-muted-foreground">{item.description}</p>
|
|
74
89
|
)}
|
|
75
90
|
</div>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
{item.meta && item.meta.length > 0 && (
|
|
92
|
+
<dl className="mt-4 grid grid-cols-2 gap-3 border-t border-border pt-4">
|
|
93
|
+
{item.meta.map((m) => (
|
|
94
|
+
<div key={m.label} className="flex min-w-0 flex-col-reverse">
|
|
95
|
+
<dt className="truncate text-[11px] text-muted-foreground">{m.label}</dt>
|
|
96
|
+
<dd className="truncate font-mono text-[14px] text-foreground tabular-nums">{m.value}</dd>
|
|
97
|
+
</div>
|
|
98
|
+
))}
|
|
99
|
+
</dl>
|
|
81
100
|
)}
|
|
82
|
-
</
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<dt className="truncate text-[11px] text-muted-foreground">{m.label}</dt>
|
|
88
|
-
<dd className="truncate font-mono text-[14px] text-foreground tabular-nums">{m.value}</dd>
|
|
89
|
-
</div>
|
|
90
|
-
))}
|
|
91
|
-
</dl>
|
|
92
|
-
)}
|
|
93
|
-
</li>
|
|
94
|
-
);
|
|
95
|
-
})}
|
|
96
|
-
</ul>
|
|
101
|
+
</li>
|
|
102
|
+
);
|
|
103
|
+
})}
|
|
104
|
+
</ul>
|
|
105
|
+
</div>
|
|
97
106
|
);
|
|
98
107
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InspectorLayout } from '@gntik-ai/ui';
|
|
2
|
+
import { ResourceCardGrid } from '../ResourceCardGrid';
|
|
3
|
+
|
|
4
|
+
export default function ContainerPanel() {
|
|
5
|
+
return (
|
|
6
|
+
<div data-container-example className="h-[640px] overflow-hidden rounded-lg border border-border">
|
|
7
|
+
<InspectorLayout panelTitle="Properties" dockedQuery="(min-width: 0px)" panel={<ResourceCardGrid />}>
|
|
8
|
+
<div className="grid gap-6 overflow-auto p-4">
|
|
9
|
+
{([3, 2, 4] as const).map((columns) => (
|
|
10
|
+
<div key={columns} data-container-slot={String(columns)} className="flex min-w-0">
|
|
11
|
+
<ResourceCardGrid columns={columns} className="gap-6" containerClassName="col-span-2" />
|
|
12
|
+
</div>
|
|
13
|
+
))}
|
|
14
|
+
</div>
|
|
15
|
+
</InspectorLayout>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -69,7 +69,7 @@ export function StatusTimeline({
|
|
|
69
69
|
return (
|
|
70
70
|
<li key={event.id} className="relative flex gap-3 pb-6 last:pb-0">
|
|
71
71
|
{!last && <span aria-hidden className="absolute top-5 bottom-0 start-[9px] w-px bg-border" />}
|
|
72
|
-
<span className="relative z-
|
|
72
|
+
<span className="relative z-raised mt-1 flex size-5 shrink-0 items-center justify-center rounded-full bg-card">
|
|
73
73
|
<StatusDot tone={event.tone} pulse={event.live} size="lg" />
|
|
74
74
|
</span>
|
|
75
75
|
<div className="min-w-0 flex-1">
|
|
@@ -4,6 +4,48 @@ import { expectNoAxeViolations } from '../../test/a11y';
|
|
|
4
4
|
import { FirstRunEmpty, NoAccessEmpty, NoResultsEmpty, NotFoundEmpty } from './EmptyStates';
|
|
5
5
|
|
|
6
6
|
describe('EmptyStates', () => {
|
|
7
|
+
it.each([undefined, { action: 'Create project' }])(
|
|
8
|
+
'allows an accessible action-free first-run state with labels=%j',
|
|
9
|
+
async (labels) => {
|
|
10
|
+
const { container } = render(
|
|
11
|
+
<FirstRunEmpty
|
|
12
|
+
title="No projects yet"
|
|
13
|
+
actionLabel={null}
|
|
14
|
+
labels={labels}
|
|
15
|
+
secondary={null}
|
|
16
|
+
steps={[]}
|
|
17
|
+
onAction={vi.fn()}
|
|
18
|
+
/>,
|
|
19
|
+
);
|
|
20
|
+
expect(screen.getByRole('heading', { name: 'No projects yet' })).toBeVisible();
|
|
21
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
22
|
+
expect(screen.queryByRole('link')).toBeNull();
|
|
23
|
+
expect(screen.queryByRole('list')).toBeNull();
|
|
24
|
+
await expectNoAxeViolations(container);
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
it('hides an empty first-run action while retaining the default guide and checklist', () => {
|
|
29
|
+
render(<FirstRunEmpty actionLabel="" />);
|
|
30
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
31
|
+
expect(screen.getByRole('link', { name: 'Read the guide' })).toBeVisible();
|
|
32
|
+
expect(screen.getByRole('list')).toBeVisible();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('hides the first-run action when its label override is empty', () => {
|
|
36
|
+
render(<FirstRunEmpty labels={{ action: '' }} />);
|
|
37
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
38
|
+
expect(screen.getByRole('link', { name: 'Read the guide' })).toBeVisible();
|
|
39
|
+
expect(screen.getByRole('list')).toBeVisible();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('calls the first-run action once with an explicit label', async () => {
|
|
43
|
+
const onAction = vi.fn();
|
|
44
|
+
render(<FirstRunEmpty actionLabel="Create" onAction={onAction} />);
|
|
45
|
+
await userEvent.setup().click(screen.getByRole('button', { name: 'Create' }));
|
|
46
|
+
expect(onAction).toHaveBeenCalledTimes(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
7
49
|
it('renders not found copy without actions or live regions, and accepts an action', async () => {
|
|
8
50
|
const { container, rerender } = render(<NotFoundEmpty title="Resource missing" description="It was deleted." />);
|
|
9
51
|
expect(screen.getByRole('heading', { name: 'Resource missing' })).toBeVisible();
|
|
@@ -55,7 +55,8 @@ export interface FirstRunEmptyProps extends SharedEmptyProps {
|
|
|
55
55
|
icon?: LucideIcon;
|
|
56
56
|
title?: ReactNode;
|
|
57
57
|
description?: ReactNode;
|
|
58
|
-
|
|
58
|
+
/** Omit to use labels.action or the localized default. `null` or "" hides the action; onAction is ignored. */
|
|
59
|
+
actionLabel?: string | null;
|
|
59
60
|
onAction?: () => void;
|
|
60
61
|
/** Secondary link (docs, guide). `null` hides it. */
|
|
61
62
|
secondary?: { label: string; href: string } | null;
|
|
@@ -81,7 +82,8 @@ export function FirstRunEmpty({
|
|
|
81
82
|
const title = titleProp === undefined ? (labels?.title ?? t('emptyState.firstRun.title')) : titleProp;
|
|
82
83
|
const description =
|
|
83
84
|
descriptionProp === undefined ? (labels?.description ?? t('emptyState.firstRun.description')) : descriptionProp;
|
|
84
|
-
const actionLabel =
|
|
85
|
+
const actionLabel =
|
|
86
|
+
actionLabelProp === undefined ? (labels?.action ?? t('emptyState.firstRun.action')) : actionLabelProp;
|
|
85
87
|
const secondary =
|
|
86
88
|
secondaryProp === undefined
|
|
87
89
|
? { label: labels?.guide ?? t('emptyState.firstRun.guide'), href: '#guide' }
|
|
@@ -94,7 +96,7 @@ export function FirstRunEmpty({
|
|
|
94
96
|
description={description}
|
|
95
97
|
bordered={bordered}
|
|
96
98
|
className={cn('mx-auto', className)}
|
|
97
|
-
primaryAction={<Button onClick={onAction}>{actionLabel}</Button>}
|
|
99
|
+
primaryAction={actionLabel ? <Button onClick={onAction}>{actionLabel}</Button> : undefined}
|
|
98
100
|
secondaryAction={
|
|
99
101
|
secondary ? (
|
|
100
102
|
<Link
|
|
@@ -215,6 +217,10 @@ export interface NoAccessEmptyProps extends SharedEmptyProps {
|
|
|
215
217
|
owner?: string;
|
|
216
218
|
/** Called on "Request access"; may return a promise (the button shows a spinner). */
|
|
217
219
|
onRequestAccess?: () => void | Promise<void>;
|
|
220
|
+
/** Show the request button and its status announcement (default true). */
|
|
221
|
+
showRequestAccess?: boolean;
|
|
222
|
+
/** One href link; secondary to the request button, or primary when the button is hidden. */
|
|
223
|
+
action?: { label: string; href: string };
|
|
218
224
|
/** Start in the "requested" state (e.g. a pending request exists). */
|
|
219
225
|
defaultRequested?: boolean;
|
|
220
226
|
}
|
|
@@ -225,6 +231,8 @@ export function NoAccessEmpty({
|
|
|
225
231
|
labels,
|
|
226
232
|
owner = noAccessSample.owner,
|
|
227
233
|
onRequestAccess,
|
|
234
|
+
showRequestAccess = true,
|
|
235
|
+
action,
|
|
228
236
|
defaultRequested = false,
|
|
229
237
|
titleAs,
|
|
230
238
|
bordered = true,
|
|
@@ -241,6 +249,11 @@ export function NoAccessEmpty({
|
|
|
241
249
|
setState('idle');
|
|
242
250
|
}
|
|
243
251
|
};
|
|
252
|
+
const actionLink = action ? (
|
|
253
|
+
<Link underline="hover" href={action.href} className="inline-flex h-9 items-center px-2 text-[13px] font-semibold">
|
|
254
|
+
{action.label}
|
|
255
|
+
</Link>
|
|
256
|
+
) : undefined;
|
|
244
257
|
return (
|
|
245
258
|
<EmptyState
|
|
246
259
|
icon={Lock}
|
|
@@ -253,22 +266,29 @@ export function NoAccessEmpty({
|
|
|
253
266
|
t('emptyState.noAccess.description', { resource: resource.toLowerCase(), owner })
|
|
254
267
|
}
|
|
255
268
|
primaryAction={
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
269
|
+
showRequestAccess ? (
|
|
270
|
+
<Button
|
|
271
|
+
variant={state === 'requested' ? 'secondary' : 'primary'}
|
|
272
|
+
icon={state === 'requested' ? Check : undefined}
|
|
273
|
+
loading={state === 'pending'}
|
|
274
|
+
disabled={state === 'requested'}
|
|
275
|
+
onClick={() => void request()}
|
|
276
|
+
>
|
|
277
|
+
{state === 'requested'
|
|
278
|
+
? (labels?.requested ?? t('emptyState.noAccess.requested'))
|
|
279
|
+
: (labels?.request ?? t('emptyState.noAccess.request'))}
|
|
280
|
+
</Button>
|
|
281
|
+
) : (
|
|
282
|
+
actionLink
|
|
283
|
+
)
|
|
267
284
|
}
|
|
285
|
+
secondaryAction={showRequestAccess ? actionLink : undefined}
|
|
268
286
|
>
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
287
|
+
{showRequestAccess && (
|
|
288
|
+
<p role="status" className="sr-only">
|
|
289
|
+
{state === 'requested' ? (labels?.sent ?? t('emptyState.noAccess.sent')) : ''}
|
|
290
|
+
</p>
|
|
291
|
+
)}
|
|
272
292
|
</EmptyState>
|
|
273
293
|
);
|
|
274
294
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
3
|
+
import { FirstRunEmpty, NoAccessEmpty } from './EmptyStates';
|
|
4
|
+
|
|
5
|
+
it.each([false, true])('omits all actions and status when hidden (defaultRequested=%s)', async (defaultRequested) => {
|
|
6
|
+
const { container } = render(<NoAccessEmpty showRequestAccess={false} defaultRequested={defaultRequested} />);
|
|
7
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
8
|
+
expect(screen.queryByRole('link')).toBeNull();
|
|
9
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
10
|
+
expect(container.querySelector('h3 + p + div')).toBeNull();
|
|
11
|
+
expect(container).not.toHaveTextContent('Access request sent');
|
|
12
|
+
await expectNoAxeViolations(container);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it.each([false, true])(
|
|
16
|
+
'offers one href action in the right position (showRequestAccess=%s)',
|
|
17
|
+
async (showRequestAccess) => {
|
|
18
|
+
const action = { label: 'Volver al resumen', href: '/x' };
|
|
19
|
+
const { container, rerender } = render(<FirstRunEmpty secondary={action} />);
|
|
20
|
+
const referenceClassName = screen.getByRole('link', { name: action.label }).className;
|
|
21
|
+
rerender(<NoAccessEmpty action={action} showRequestAccess={showRequestAccess} />);
|
|
22
|
+
const link = screen.getByRole('link', { name: action.label });
|
|
23
|
+
expect(screen.getAllByRole('link')).toHaveLength(1);
|
|
24
|
+
expect(link).toHaveAttribute('href', '/x');
|
|
25
|
+
expect(link.className).toBe(referenceClassName);
|
|
26
|
+
expect(link.parentElement?.parentElement).toBe(container.firstElementChild);
|
|
27
|
+
if (showRequestAccess) {
|
|
28
|
+
const button = screen.getByRole('button', { name: 'Request access' });
|
|
29
|
+
expect(screen.getAllByRole('button')).toHaveLength(1);
|
|
30
|
+
expect(Array.from(link.parentElement!.children)).toEqual([button, link]);
|
|
31
|
+
} else {
|
|
32
|
+
expect(screen.queryByRole('button')).toBeNull();
|
|
33
|
+
expect(screen.queryByRole('status')).toBeNull();
|
|
34
|
+
expect(Array.from(link.parentElement!.children)).toEqual([link]);
|
|
35
|
+
}
|
|
36
|
+
await expectNoAxeViolations(container);
|
|
37
|
+
},
|
|
38
|
+
);
|
|
@@ -5,7 +5,7 @@ export const meta: BlockMeta = {
|
|
|
5
5
|
family: 'feedback',
|
|
6
6
|
status: 'beta',
|
|
7
7
|
description:
|
|
8
|
-
'Four canonical empty states: first run (with checklist), no results (clear filters/search), no access (request access) and not found (optional action). FirstRunEmpty, NoResultsEmpty and NoAccessEmpty accept labels?: Partial<FirstRunEmptyLabels>, Partial<NoResultsEmptyLabels> and Partial<NoAccessEmptyLabels> respectively. Each type has its own keys below; explicit title, description, actionLabel and secondary props win. Defaults follow I18nProvider (en/es). NoResultsEmpty keeps the query in a mono span unless queryTitle replaces the heading. NotFoundEmpty and all imported fixtures stay English. See the Catalog labels live preview.',
|
|
8
|
+
'Four canonical empty states: first run (with checklist), no results (clear filters/search), no access (request access) and not found (optional action). FirstRunEmpty, NoResultsEmpty and NoAccessEmpty accept labels?: Partial<FirstRunEmptyLabels>, Partial<NoResultsEmptyLabels> and Partial<NoAccessEmptyLabels> respectively. Each type has its own keys below; explicit title, description, actionLabel and secondary props win. FirstRunEmpty accepts actionLabel?: string | null: omitting it uses labels.action or the localized default; actionLabel={null} or actionLabel="" hides the primary action and ignores onAction. An empty labels.action also hides it. Combine actionLabel={null}, secondary={null} and steps={[]} for a state with no actions or checklist. See the Hidden action live preview. Defaults follow I18nProvider (en/es). NoResultsEmpty keeps the query in a mono span unless queryTitle replaces the heading. NotFoundEmpty and all imported fixtures stay English. See the Catalog labels live preview. NoAccessEmpty accepts showRequestAccess?: boolean (default true): false hides both the request button and its status announcement, so defaultRequested has no visible effect. action?: { label: string; href: string } renders one kit Link, styled like FirstRunEmpty’s secondary link; it is secondaryAction after the request button, or primaryAction when showRequestAccess is false. With showRequestAccess=false and no action, it renders no actions. Omitting onRequestAccess still shows the button by default. See the Spanish live preview for no actions, a link alone, and a link with the request button.',
|
|
9
9
|
labels: [
|
|
10
10
|
{
|
|
11
11
|
key: 'FirstRunEmpty.labels.title',
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FirstRunEmpty } from '../EmptyStates';
|
|
2
|
+
|
|
3
|
+
export default function HiddenAction() {
|
|
4
|
+
return (
|
|
5
|
+
<FirstRunEmpty
|
|
6
|
+
title="No projects yet"
|
|
7
|
+
description="Projects will appear here when they are available."
|
|
8
|
+
actionLabel={null}
|
|
9
|
+
secondary={null}
|
|
10
|
+
steps={[]}
|
|
11
|
+
/>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -35,6 +35,13 @@ export default function Spanish() {
|
|
|
35
35
|
sent: 'Your request was sent',
|
|
36
36
|
}}
|
|
37
37
|
/>
|
|
38
|
+
<NoAccessEmpty resource="Restricted settings" showRequestAccess={false} />
|
|
39
|
+
<NoAccessEmpty
|
|
40
|
+
resource="Restricted resource"
|
|
41
|
+
showRequestAccess={false}
|
|
42
|
+
action={{ label: 'Back to overview', href: '#overview' }}
|
|
43
|
+
/>
|
|
44
|
+
<NoAccessEmpty resource="Shared resource" action={{ label: 'Back to overview', href: '#overview' }} />
|
|
38
45
|
</Stack>
|
|
39
46
|
</I18nProvider>
|
|
40
47
|
);
|