@gntik-ai/blocks 0.11.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 +1501 -1232
- package/dist/index.js +1884 -836
- 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.test.tsx +6 -0
- package/src/auth/ForgotPasswordForm/ForgotPasswordForm.tsx +4 -1
- package/src/auth/ForgotPasswordForm/block.meta.ts +1 -1
- package/src/auth/ForgotPasswordForm/examples/LargeFields.tsx +6 -0
- package/src/auth/MfaChallenge/MfaChallenge.test.tsx +9 -0
- package/src/auth/MfaChallenge/MfaChallenge.tsx +5 -2
- package/src/auth/MfaChallenge/block.meta.ts +1 -1
- package/src/auth/MfaChallenge/examples/LargeFields.tsx +6 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.test.tsx +7 -0
- package/src/auth/ResetPasswordForm/ResetPasswordForm.tsx +5 -3
- package/src/auth/ResetPasswordForm/block.meta.ts +1 -1
- package/src/auth/ResetPasswordForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SignInForm/SignInForm.test.tsx +7 -0
- package/src/auth/SignInForm/SignInForm.tsx +5 -1
- package/src/auth/SignInForm/block.meta.ts +1 -1
- package/src/auth/SignInForm/examples/LargeFields.tsx +6 -0
- package/src/auth/SignUpForm/SignUpForm.test.tsx +22 -0
- package/src/auth/SignUpForm/SignUpForm.tsx +7 -1
- package/src/auth/SignUpForm/block.meta.ts +1 -1
- package/src/auth/SignUpForm/examples/LargeFields.tsx +6 -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.tsx +7 -2
- 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.test.tsx +24 -0
- package/src/builders/LogViewer/LogViewer.tsx +67 -20
- package/src/builders/LogViewer/block.meta.ts +2 -1
- package/src/builders/LogViewer/examples/Spanish.tsx +2 -1
- 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.test.tsx +24 -1
- package/src/data-display/DescriptionListCard/DescriptionListCard.tsx +14 -20
- package/src/data-display/DescriptionListCard/block.meta.ts +2 -1
- package/src/data-display/DescriptionListCard/examples/Spanish.tsx +2 -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 +5 -3
- package/src/feedback/EmptyStates/block.meta.ts +1 -1
- package/src/feedback/EmptyStates/examples/HiddenAction.tsx +13 -0
- package/src/feedback/ErrorPanel/ErrorPanel.tsx +13 -15
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.lifecycle.test.tsx +123 -0
- package/src/forms/CreateApiKeyDialog/CreateApiKeyDialog.tsx +128 -139
- package/src/forms/CreateApiKeyDialog/block.meta.ts +12 -1
- 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.lifecycle.test.tsx +165 -0
- package/src/forms/FileUploadPanel/FileUploadPanel.tsx +267 -69
- package/src/forms/FileUploadPanel/block.meta.ts +5 -1
- package/src/forms/FileUploadPanel/examples/AutoCancel.tsx +38 -0
- package/src/forms/FileUploadPanel/examples/Labels.tsx +1 -1
- 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.test.tsx +11 -0
- package/src/forms/FormSection/FormSection.tsx +20 -22
- package/src/forms/FormSection/block.meta.ts +1 -1
- package/src/forms/FormSection/examples/ContainerPanel.tsx +16 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.lifecycle.test.tsx +80 -0
- package/src/forms/InviteMembersDialog/InviteMembersDialog.tsx +90 -109
- package/src/forms/InviteMembersDialog/block.meta.ts +1 -1
- package/src/forms/ValidationSummary/ValidationSummary.tsx +1 -4
- 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.tsx +4 -4
- 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/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.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.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 +328 -14
- package/src/tables/DataTable/DataTable.test.tsx +85 -1
- package/src/tables/DataTable/DataTable.tsx +108 -14
- package/src/tables/DataTable/block.meta.ts +11 -1
- package/src/tables/DataTable/column-sizing.ts +2 -2
- package/src/tables/DataTable/data-table-props.ts +29 -1
- package/src/tables/DataTable/data-table-row.tsx +2 -2
- package/src/tables/DataTable/data-table-utils.ts +4 -0
- package/src/tables/DataTable/editable-cell.tsx +20 -79
- 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/server-pagination.tsx +47 -40
- package/src/tables/DataTable/export-menu.tsx +58 -0
- package/src/tables/DataTable/header-cell.tsx +1 -1
- package/src/tables/DataTable/labels.ts +7 -0
- package/src/tables/DataTable/resize-handle.tsx +2 -2
- 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 +10 -1
- 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 +5 -5
- package/src/test/without-forced-colors.test.ts +44 -0
- package/src/test/without-forced-colors.ts +14 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
2
|
+
import { SignInForm } from './SignInForm/SignInForm';
|
|
3
|
+
import { SignUpForm } from './SignUpForm/SignUpForm';
|
|
4
|
+
import { ResetPasswordForm } from './ResetPasswordForm/ResetPasswordForm';
|
|
5
|
+
import { ForgotPasswordForm } from './ForgotPasswordForm/ForgotPasswordForm';
|
|
6
|
+
import { MfaChallenge } from './MfaChallenge/MfaChallenge';
|
|
7
|
+
|
|
8
|
+
// Captured before adding fieldSize: default auth markup must remain identical.
|
|
9
|
+
describe('auth default markup', () => {
|
|
10
|
+
it.each([
|
|
11
|
+
['SignInForm', SignInForm],
|
|
12
|
+
['SignUpForm', SignUpForm],
|
|
13
|
+
['ResetPasswordForm', ResetPasswordForm],
|
|
14
|
+
['ForgotPasswordForm', ForgotPasswordForm],
|
|
15
|
+
['MfaChallenge', MfaChallenge],
|
|
16
|
+
] as const)('%s retains its default markup', (_name, Form) => {
|
|
17
|
+
const markup = renderToStaticMarkup(<Form />);
|
|
18
|
+
expect(markup).toMatchSnapshot();
|
|
19
|
+
expect(renderToStaticMarkup(<Form fieldSize="auto" />)).toBe(markup);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ThemeProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { expectNoAxeViolations } from '../test/a11y';
|
|
5
|
+
import SignInLarge from './SignInForm/examples/LargeFields';
|
|
6
|
+
import SignUpLarge from './SignUpForm/examples/LargeFields';
|
|
7
|
+
import ResetLarge from './ResetPasswordForm/examples/LargeFields';
|
|
8
|
+
import ForgotLarge from './ForgotPasswordForm/examples/LargeFields';
|
|
9
|
+
import MfaLarge from './MfaChallenge/examples/LargeFields';
|
|
10
|
+
|
|
11
|
+
for (const theme of ['dark', 'light', 'high_contrast'] as const) {
|
|
12
|
+
it.each([
|
|
13
|
+
['sign-in', SignInLarge],
|
|
14
|
+
['sign-up', SignUpLarge],
|
|
15
|
+
['reset', ResetLarge],
|
|
16
|
+
['forgot', ForgotLarge],
|
|
17
|
+
['mfa', MfaLarge],
|
|
18
|
+
] as const)('%s large example is accessible in ' + theme, async (name, Example) => {
|
|
19
|
+
const { container } = render(
|
|
20
|
+
<ThemeProvider defaultMode={theme} storageKey={null}>
|
|
21
|
+
<Example />
|
|
22
|
+
</ThemeProvider>,
|
|
23
|
+
);
|
|
24
|
+
await expectNoAxeViolations(container);
|
|
25
|
+
if (name === 'mfa') {
|
|
26
|
+
await userEvent.click(screen.getByRole('button', { name: 'Use a backup code' }));
|
|
27
|
+
await expectNoAxeViolations(container);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
package/src/auth/shared.tsx
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { cn, en, useI18n, type I18n } from '@gntik-ai/ui';
|
|
2
2
|
import { useState, type ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
+
export interface AuthFieldSizeProps {
|
|
5
|
+
/** Field size: auto follows density (default); lg matches the 44px submit button. */
|
|
6
|
+
fieldSize?: 'auto' | 'lg';
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
export interface AuthHeaderProps {
|
|
5
10
|
eyebrow?: ReactNode;
|
|
6
11
|
title: ReactNode;
|
|
@@ -15,7 +20,7 @@ export function AuthHeader({ eyebrow, title, description, headingLevel: Heading
|
|
|
15
20
|
return (
|
|
16
21
|
<div className={cn('mb-6', className)}>
|
|
17
22
|
{eyebrow != null && (
|
|
18
|
-
<p className="mb-2.5 font-mono text-[11px] tracking-[0.2em] text-primary-text
|
|
23
|
+
<p className="mb-2.5 font-mono text-[11px] tracking-[0.2em] text-primary-text label-case">{eyebrow}</p>
|
|
19
24
|
)}
|
|
20
25
|
{Heading != null && title != null && (
|
|
21
26
|
<Heading className="text-[24px] font-semibold tracking-tight text-balance text-foreground sm:text-[27px]">
|
|
@@ -34,7 +39,7 @@ export function AuthDivider({ children }: { children: ReactNode }) {
|
|
|
34
39
|
return (
|
|
35
40
|
<div className="my-6 flex items-center gap-3" role="presentation">
|
|
36
41
|
<span className="h-px flex-1 bg-border" />
|
|
37
|
-
<span className="font-mono text-[10.5px] font-semibold tracking-[0.2em] text-muted-foreground
|
|
42
|
+
<span className="font-mono text-[10.5px] font-semibold tracking-[0.2em] text-muted-foreground label-case">
|
|
38
43
|
{children}
|
|
39
44
|
</span>
|
|
40
45
|
<span className="h-px flex-1 bg-border" />
|
|
@@ -75,7 +75,7 @@ export function PaymentMethodCard({
|
|
|
75
75
|
<div className="flex flex-wrap items-center gap-4 px-5 py-4">
|
|
76
76
|
<span
|
|
77
77
|
aria-hidden
|
|
78
|
-
className="grid h-10 w-14 shrink-0 place-items-center rounded-md border border-border bg-secondary font-mono text-[10.5px] font-semibold tracking-wide text-foreground
|
|
78
|
+
className="grid h-10 w-14 shrink-0 place-items-center rounded-md border border-border bg-secondary font-mono text-[10.5px] font-semibold tracking-wide text-foreground label-case"
|
|
79
79
|
>
|
|
80
80
|
{method.brand.slice(0, 4)}
|
|
81
81
|
</span>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { render } from '@testing-library/react';
|
|
2
2
|
import { PlanCard, type BillingPlan } from './PlanCard';
|
|
3
|
+
import { withoutForcedColors } from '../../test/without-forced-colors';
|
|
3
4
|
|
|
4
5
|
const full: BillingPlan = {
|
|
5
6
|
name: 'Fixture Plan',
|
|
@@ -16,11 +17,11 @@ const full: BillingPlan = {
|
|
|
16
17
|
describe('PlanCard billing DOM baseline', () => {
|
|
17
18
|
it('preserves the no-props billing header', () => {
|
|
18
19
|
const { container } = render(<PlanCard />);
|
|
19
|
-
expect(container.outerHTML).toMatchSnapshot();
|
|
20
|
+
expect(withoutForcedColors(container).outerHTML).toMatchSnapshot();
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
it('preserves the FULL billing header', () => {
|
|
23
24
|
const { container } = render(<PlanCard plan={full} upgradeLabel="Upgrade" manageLabel="Manage" />);
|
|
24
|
-
expect(container.outerHTML).toMatchSnapshot();
|
|
25
|
+
expect(withoutForcedColors(container).outerHTML).toMatchSnapshot();
|
|
25
26
|
});
|
|
26
27
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
-
exports[`PlanCard billing DOM baseline > preserves the FULL billing header 1`] = `"<div><div class="overflow-hidden rounded-xl border border-border text-card-foreground bg-card shadow-sm p-6"><div class="flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between"><div class="min-w-0"><div class="flex flex-wrap items-center gap-2"><h3 class="text-[17px] font-semibold tracking-tight text-foreground">Fixture Plan plan</h3><span class="inline-flex max-w-full shrink-0 items-center gap-1.5 font-semibold whitespace-nowrap select-none h-chip px-2.5 font-mono text-[10.5px] rounded-md
|
|
3
|
+
exports[`PlanCard billing DOM baseline > preserves the FULL billing header 1`] = `"<div><div class="overflow-hidden rounded-xl border border-border text-card-foreground bg-card shadow-sm p-6"><div class="flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between"><div class="min-w-0"><div class="flex flex-wrap items-center gap-2"><h3 class="text-[17px] font-semibold tracking-tight text-foreground">Fixture Plan plan</h3><span data-tone="success" class="inline-flex max-w-full shrink-0 items-center gap-1.5 font-semibold whitespace-nowrap select-none [--badge-bg-alpha:15%] [--badge-border-alpha:45%] bg-tone/(--badge-bg-alpha) text-tone-chip-text h-chip px-2.5 font-mono text-[10.5px] rounded-md"><span aria-hidden="true" class="size-1.5 shrink-0 rounded-full bg-tone"></span>Active</span></div><p class="mt-1 text-[13px] text-muted-foreground">Renews January 1, 2027 · 2 seats</p><p class="mt-4 flex items-baseline gap-1.5"><span class="text-[30px] font-semibold tracking-tight text-foreground tabular-nums">€10</span><span class="text-[13px] text-muted-foreground">/ month</span></p><p class="mt-1 text-[12px] text-muted-foreground">Billed monthly</p></div><div class="flex flex-col items-start gap-3 sm:items-end"><div data-orientation="horizontal" role="group" aria-label="Billing cycle" class="inline-flex data-[orientation=vertical]:flex-col data-disabled:opacity-50 items-center gap-0.5 rounded-lg border border-border bg-card p-0.5 shadow-sm"><button type="button" data-pressed="" aria-disabled="false" tabindex="0" aria-pressed="true" class="inline-flex shrink-0 items-center justify-center gap-2 font-medium whitespace-nowrap text-muted-foreground transition-colors select-none hover:text-foreground data-pressed:bg-secondary data-pressed:text-foreground focus-visible:relative focus-visible:z-raised focus-ring data-disabled:cursor-disabled data-disabled:opacity-50 data-disabled:hover:text-muted-foreground rounded-md data-pressed:shadow-sm h-7 px-2.5 text-[12px]">Monthly</button><button type="button" aria-disabled="false" tabindex="-1" aria-pressed="false" class="inline-flex shrink-0 items-center justify-center gap-2 font-medium whitespace-nowrap text-muted-foreground transition-colors select-none hover:text-foreground data-pressed:bg-secondary data-pressed:text-foreground focus-visible:relative focus-visible:z-raised focus-ring data-disabled:cursor-disabled data-disabled:opacity-50 data-disabled:hover:text-muted-foreground rounded-md data-pressed:shadow-sm h-7 px-2.5 text-[12px]">Annual</button></div><div class="flex flex-wrap items-center gap-2"><button type="button" tabindex="0" class="inline-flex shrink-0 items-center justify-center font-semibold whitespace-nowrap transition-colors select-none cursor-interactive focus-ring data-[disabled]:cursor-disabled data-[disabled]:opacity-50 border border-border bg-card text-foreground shadow-sm not-data-[disabled]:hover:bg-secondary/70 h-control gap-1.5 px-control text-[13px] rounded-lg">Manage</button><button type="button" tabindex="0" class="inline-flex shrink-0 items-center justify-center font-semibold whitespace-nowrap transition-colors select-none cursor-interactive focus-ring data-[disabled]:cursor-disabled data-[disabled]:opacity-50 bg-primary text-primary-foreground shadow-sm not-data-[disabled]:hover:bg-primary/90 h-control gap-1.5 px-control text-[13px] rounded-lg"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sparkles lucide-stars" aria-hidden="true"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"></path><path d="M20 2v4"></path><path d="M22 4h-4"></path><circle cx="4" cy="20" r="2"></circle></svg>Upgrade</button></div></div></div><ul aria-label="Fixture Plan plan features" class="mt-5 grid gap-x-6 gap-y-2 border-t border-border pt-5 sm:grid-cols-2"><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>Feature A</li><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>Feature B</li></ul></div></div>"`;
|
|
4
4
|
|
|
5
|
-
exports[`PlanCard billing DOM baseline > preserves the no-props billing header 1`] = `"<div><div class="overflow-hidden rounded-xl border border-border text-card-foreground bg-card shadow-sm p-6"><div class="flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between"><div class="min-w-0"><div class="flex flex-wrap items-center gap-2"><h3 class="text-[17px] font-semibold tracking-tight text-foreground">Scale plan</h3><span class="inline-flex max-w-full shrink-0 items-center gap-1.5 font-semibold whitespace-nowrap select-none h-chip px-2.5 font-mono text-[10.5px] rounded-md
|
|
5
|
+
exports[`PlanCard billing DOM baseline > preserves the no-props billing header 1`] = `"<div><div class="overflow-hidden rounded-xl border border-border text-card-foreground bg-card shadow-sm p-6"><div class="flex flex-col gap-5 sm:flex-row sm:items-start sm:justify-between"><div class="min-w-0"><div class="flex flex-wrap items-center gap-2"><h3 class="text-[17px] font-semibold tracking-tight text-foreground">Scale plan</h3><span data-tone="success" class="inline-flex max-w-full shrink-0 items-center gap-1.5 font-semibold whitespace-nowrap select-none [--badge-bg-alpha:15%] [--badge-border-alpha:45%] bg-tone/(--badge-bg-alpha) text-tone-chip-text h-chip px-2.5 font-mono text-[10.5px] rounded-md"><span aria-hidden="true" class="size-1.5 shrink-0 rounded-full bg-tone"></span>Active</span></div><p class="mt-1 text-[13px] text-muted-foreground">Renews June 1, 2026 · 50 seats · 2 regions</p><p class="mt-4 flex items-baseline gap-1.5"><span class="text-[30px] font-semibold tracking-tight text-foreground tabular-nums">$1,200</span><span class="text-[13px] text-muted-foreground">/ month</span></p><p class="mt-1 text-[12px] text-muted-foreground">Billed monthly</p></div><div class="flex flex-col items-start gap-3 sm:items-end"><div data-orientation="horizontal" role="group" aria-label="Billing cycle" class="inline-flex data-[orientation=vertical]:flex-col data-disabled:opacity-50 items-center gap-0.5 rounded-lg border border-border bg-card p-0.5 shadow-sm"><button type="button" data-pressed="" aria-disabled="false" tabindex="0" aria-pressed="true" class="inline-flex shrink-0 items-center justify-center gap-2 font-medium whitespace-nowrap text-muted-foreground transition-colors select-none hover:text-foreground data-pressed:bg-secondary data-pressed:text-foreground focus-visible:relative focus-visible:z-raised focus-ring data-disabled:cursor-disabled data-disabled:opacity-50 data-disabled:hover:text-muted-foreground rounded-md data-pressed:shadow-sm h-7 px-2.5 text-[12px]">Monthly</button><button type="button" aria-disabled="false" tabindex="-1" aria-pressed="false" class="inline-flex shrink-0 items-center justify-center gap-2 font-medium whitespace-nowrap text-muted-foreground transition-colors select-none hover:text-foreground data-pressed:bg-secondary data-pressed:text-foreground focus-visible:relative focus-visible:z-raised focus-ring data-disabled:cursor-disabled data-disabled:opacity-50 data-disabled:hover:text-muted-foreground rounded-md data-pressed:shadow-sm h-7 px-2.5 text-[12px]">Annual −17%</button></div><div class="flex flex-wrap items-center gap-2"><button type="button" tabindex="0" class="inline-flex shrink-0 items-center justify-center font-semibold whitespace-nowrap transition-colors select-none cursor-interactive focus-ring data-[disabled]:cursor-disabled data-[disabled]:opacity-50 border border-border bg-card text-foreground shadow-sm not-data-[disabled]:hover:bg-secondary/70 h-control gap-1.5 px-control text-[13px] rounded-lg">Manage</button><button type="button" tabindex="0" class="inline-flex shrink-0 items-center justify-center font-semibold whitespace-nowrap transition-colors select-none cursor-interactive focus-ring data-[disabled]:cursor-disabled data-[disabled]:opacity-50 bg-primary text-primary-foreground shadow-sm not-data-[disabled]:hover:bg-primary/90 h-control gap-1.5 px-control text-[13px] rounded-lg"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-sparkles lucide-stars" aria-hidden="true"><path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z"></path><path d="M20 2v4"></path><path d="M22 4h-4"></path><circle cx="4" cy="20" r="2"></circle></svg>Upgrade plan</button></div></div></div><ul aria-label="Scale plan features" class="mt-5 grid gap-x-6 gap-y-2 border-t border-border pt-5 sm:grid-cols-2"><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>500,000 requests / month</li><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>120M tokens / month</li><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>20 GB storage</li><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>Audit log and SSO</li><li class="flex items-start gap-2 text-[13px] text-foreground"><svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check mt-0.5 shrink-0 text-primary-text" aria-hidden="true"><path d="M20 6 9 17l-5-5"></path></svg>Email support · 1 business day</li></ul></div></div>"`;
|
|
@@ -10,10 +10,7 @@ export default function Compact() {
|
|
|
10
10
|
actions={
|
|
11
11
|
<>
|
|
12
12
|
<Button onClick={() => window.alert('Edit')}>Edit</Button>
|
|
13
|
-
<a
|
|
14
|
-
href="#tenants"
|
|
15
|
-
className="text-primary-text underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
|
|
16
|
-
>
|
|
13
|
+
<a href="#tenants" className="text-primary-text underline focus-ring">
|
|
17
14
|
View tenants
|
|
18
15
|
</a>
|
|
19
16
|
</>
|
|
@@ -10,10 +10,7 @@ export default function Full() {
|
|
|
10
10
|
actions={
|
|
11
11
|
<>
|
|
12
12
|
<Button onClick={() => window.alert('Edit')}>Edit</Button>
|
|
13
|
-
<a
|
|
14
|
-
href="#tenants"
|
|
15
|
-
className="text-primary-text underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring"
|
|
16
|
-
>
|
|
13
|
+
<a href="#tenants" className="text-primary-text underline focus-ring">
|
|
17
14
|
View tenants
|
|
18
15
|
</a>
|
|
19
16
|
</>
|
|
@@ -198,7 +198,7 @@ export function CodePanel({
|
|
|
198
198
|
</Tabs>
|
|
199
199
|
<div className="border-t border-border">
|
|
200
200
|
<div className="flex items-center gap-3 bg-secondary/35 px-3 py-2">
|
|
201
|
-
<ProblemsHeading className="text-[12px] font-semibold tracking-wide text-foreground
|
|
201
|
+
<ProblemsHeading className="text-[12px] font-semibold tracking-wide text-foreground label-case">
|
|
202
202
|
Problems
|
|
203
203
|
</ProblemsHeading>
|
|
204
204
|
<span className="font-mono text-[11px] text-muted-foreground">
|
|
@@ -217,7 +217,7 @@ export function CodePanel({
|
|
|
217
217
|
<button
|
|
218
218
|
type="button"
|
|
219
219
|
onClick={() => selectProblem(p)}
|
|
220
|
-
className="flex w-full items-start gap-2 px-3 py-1.5 text-start text-[12.5px] hover:bg-secondary/60 focus-
|
|
220
|
+
className="flex w-full items-start gap-2 px-3 py-1.5 text-start text-[12.5px] hover:bg-secondary/60 focus-ring-inset"
|
|
221
221
|
>
|
|
222
222
|
<SevIcon size={14} aria-hidden className={cn('mt-0.5 shrink-0', sev.className)} />
|
|
223
223
|
<span className="sr-only">{sev.label}:</span>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { useEffect, useRef, useState,
|
|
1
|
+
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
|
2
|
+
import { breakpointQuery } from '@gntik-ai/tokens/runtime';
|
|
2
3
|
import { Play } from '@gntik-ai/icons';
|
|
3
4
|
import { FlowCanvas, type FlowCanvasProps, type FlowNode, type FlowNodeData, type FlowNodeKind } from '@gntik-ai/flow';
|
|
4
|
-
import { Button, ResizablePanel, ResizablePanelGroup, ResizeHandle, cn } from '@gntik-ai/ui';
|
|
5
|
+
import { Button, ResizablePanel, ResizablePanelGroup, ResizeHandle, cn, useMediaQuery } from '@gntik-ai/ui';
|
|
5
6
|
import {
|
|
6
7
|
builderConsole,
|
|
7
8
|
builderEdges,
|
|
@@ -88,22 +89,6 @@ export interface FlowBuilderProps<Kind extends string = FlowNodeKind> extends Fl
|
|
|
88
89
|
export type FlowRunResult = ConsoleEntry[] | void | undefined;
|
|
89
90
|
|
|
90
91
|
const NO_ISSUES: NonNullable<FlowBuilderProps['validationIssues']> = [];
|
|
91
|
-
const WIDE_QUERY = '(min-width: 768px)';
|
|
92
|
-
|
|
93
|
-
function subscribeWide(onChange: () => void) {
|
|
94
|
-
if (typeof window === 'undefined' || !window.matchMedia) return () => {};
|
|
95
|
-
const mql = window.matchMedia(WIDE_QUERY);
|
|
96
|
-
mql.addEventListener?.('change', onChange);
|
|
97
|
-
return () => mql.removeEventListener?.('change', onChange);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function useIsWide() {
|
|
101
|
-
return useSyncExternalStore(
|
|
102
|
-
subscribeWide,
|
|
103
|
-
() => (typeof window !== 'undefined' && window.matchMedia ? window.matchMedia(WIDE_QUERY).matches : true),
|
|
104
|
-
() => true,
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
92
|
|
|
108
93
|
function clock() {
|
|
109
94
|
return new Date().toLocaleTimeString('en-GB', { hour12: false });
|
|
@@ -144,7 +129,7 @@ export function FlowBuilder<Kind extends string = FlowNodeKind>({
|
|
|
144
129
|
const flow = useRef<
|
|
145
130
|
Parameters<NonNullable<FlowCanvasProps<FlowNode<Kind | FlowNodeKind>, FlowEdge>['onInit']>>[0] | null
|
|
146
131
|
>(null);
|
|
147
|
-
const wide =
|
|
132
|
+
const wide = useMediaQuery(breakpointQuery('md'), true);
|
|
148
133
|
const panelAs = TitleTag === 'h2' ? 'h3' : TitleTag === 'h3' ? 'h4' : 'h5';
|
|
149
134
|
const { nodes, edges, setNodes, setEdges, onNodesChange, onEdgesChange } = useBuilderGraph<Kind>(
|
|
150
135
|
{ nodes: initialNodes, edges: initialEdges },
|
|
@@ -16,7 +16,7 @@ import type { ConsoleEntry, PaletteItem } from './fixtures';
|
|
|
16
16
|
export type PanelHeading = 'h3' | 'h4' | 'h5';
|
|
17
17
|
|
|
18
18
|
const panelTitle =
|
|
19
|
-
'px-3 pt-3 pb-2 font-mono text-[10.5px] font-medium tracking-[0.12em] text-muted-foreground
|
|
19
|
+
'px-3 pt-3 pb-2 font-mono text-[10.5px] font-medium tracking-[0.12em] text-muted-foreground label-case';
|
|
20
20
|
|
|
21
21
|
export interface NodePaletteProps {
|
|
22
22
|
items: PaletteItem[];
|
|
@@ -41,7 +41,7 @@ export function NodePalette({ items, onAdd, titleAs: TitleTag = 'h3' }: NodePale
|
|
|
41
41
|
onClick={() => onAdd(item)}
|
|
42
42
|
aria-label={`Add ${item.title}`}
|
|
43
43
|
title={item.description}
|
|
44
|
-
className="group flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-start hover:bg-secondary/70 focus-
|
|
44
|
+
className="group flex w-full items-center gap-2.5 rounded-md px-2 py-2 text-start hover:bg-secondary/70 focus-ring"
|
|
45
45
|
>
|
|
46
46
|
<span className={cn('grid size-7 shrink-0 place-items-center rounded-md', KIND_CHIP[item.kind])}>
|
|
47
47
|
<KindGlyph kind={item.kind} size={14} />
|
|
@@ -177,7 +177,7 @@ export function RunConsole({ entries, onClear, titleAs: TitleTag = 'h3' }: RunCo
|
|
|
177
177
|
role="log"
|
|
178
178
|
aria-label="Run console"
|
|
179
179
|
tabIndex={0}
|
|
180
|
-
className="flex-1 overflow-y-auto px-3 py-2 font-mono text-[11.5px] focus-
|
|
180
|
+
className="flex-1 overflow-y-auto px-3 py-2 font-mono text-[11.5px] focus-ring-inset"
|
|
181
181
|
>
|
|
182
182
|
{entries.length === 0 ? (
|
|
183
183
|
<p className="font-sans text-[12.5px] text-muted-foreground">No output yet. Run the flow to see its steps.</p>
|
|
@@ -185,7 +185,7 @@ export function RunConsole({ entries, onClear, titleAs: TitleTag = 'h3' }: RunCo
|
|
|
185
185
|
entries.map((e) => (
|
|
186
186
|
<p key={e.id} className="flex gap-3 py-0.5">
|
|
187
187
|
<span className="shrink-0 text-muted-foreground tabular-nums">{e.time}</span>
|
|
188
|
-
<span className={cn('w-14 shrink-0
|
|
188
|
+
<span className={cn('w-14 shrink-0 label-case', CONSOLE_LEVEL[e.level])}>{e.level}</span>
|
|
189
189
|
<span className="min-w-0 text-foreground">{e.message}</span>
|
|
190
190
|
</p>
|
|
191
191
|
))
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { act, fireEvent, render, screen } from '@testing-library/react';
|
|
2
|
+
import { LogViewer } from './LogViewer';
|
|
3
|
+
import { makeLogLines } from './fixtures';
|
|
4
|
+
|
|
5
|
+
afterEach(() => vi.restoreAllMocks());
|
|
6
|
+
|
|
7
|
+
it('preserves an upward scroll when row measurement commits before the browser scroll event', () => {
|
|
8
|
+
let rowHeight = 24;
|
|
9
|
+
const rect = Element.prototype.getBoundingClientRect;
|
|
10
|
+
vi.spyOn(Element.prototype, 'getBoundingClientRect').mockImplementation(function (this: Element) {
|
|
11
|
+
const result = rect.call(this);
|
|
12
|
+
return this.matches('[data-slot="log-line"]') ? { ...result, height: rowHeight } : result;
|
|
13
|
+
});
|
|
14
|
+
const lines = makeLogLines(40);
|
|
15
|
+
const view = render(<LogViewer lines={lines} wrap height={240} />);
|
|
16
|
+
const log = screen.getByRole('log');
|
|
17
|
+
const follow = screen.getByRole('switch', { name: 'Follow' });
|
|
18
|
+
expect(log.scrollTop).toBeGreaterThan(0);
|
|
19
|
+
expect(follow).toBeChecked();
|
|
20
|
+
|
|
21
|
+
// The browser changes scrollTop immediately, but dispatches scroll later.
|
|
22
|
+
log.scrollTop = 0;
|
|
23
|
+
rowHeight = 48;
|
|
24
|
+
act(() => view.rerender(<LogViewer lines={lines} wrap height={240} />));
|
|
25
|
+
fireEvent.scroll(log);
|
|
26
|
+
|
|
27
|
+
expect(follow).not.toBeChecked();
|
|
28
|
+
expect(log.scrollTop).toBe(0);
|
|
29
|
+
});
|
|
@@ -7,6 +7,30 @@ import { makeLogLines } from './fixtures';
|
|
|
7
7
|
const renderedLines = () => document.querySelectorAll('[data-slot="log-line"]');
|
|
8
8
|
|
|
9
9
|
describe('LogViewer', () => {
|
|
10
|
+
it.each(['rejected', 'missing'] as const)(
|
|
11
|
+
'reports a %s clipboard write only on that line without calling onCopyLine',
|
|
12
|
+
async (failure) => {
|
|
13
|
+
userEvent.setup();
|
|
14
|
+
const clipboard = navigator.clipboard;
|
|
15
|
+
if (failure === 'missing')
|
|
16
|
+
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: undefined });
|
|
17
|
+
else vi.spyOn(navigator.clipboard, 'writeText').mockRejectedValue(new DOMException('Denied', 'NotAllowedError'));
|
|
18
|
+
const onCopyLine = vi.fn();
|
|
19
|
+
try {
|
|
20
|
+
render(<LogViewer lines={makeLogLines(2)} onCopyLine={onCopyLine} />);
|
|
21
|
+
fireEvent.click(screen.getByRole('button', { name: 'Copy line 12:00:00.000' }));
|
|
22
|
+
const button = await screen.findByRole('button', { name: 'Copy failed' });
|
|
23
|
+
expect(button.closest('[data-slot="log-line"]')).toHaveTextContent('12:00:00.000');
|
|
24
|
+
expect(screen.getAllByRole('button', { name: /^Copy line/ })).toHaveLength(1);
|
|
25
|
+
expect(screen.queryByRole('button', { name: 'Copied' })).toBeNull();
|
|
26
|
+
expect(button.querySelector('.lucide-check')).toBeNull();
|
|
27
|
+
expect(onCopyLine).not.toHaveBeenCalled();
|
|
28
|
+
} finally {
|
|
29
|
+
Object.defineProperty(navigator, 'clipboard', { configurable: true, value: clipboard });
|
|
30
|
+
vi.restoreAllMocks();
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
);
|
|
10
34
|
it('follows the bottom, stops after scrolling up more than a row and resumes on demand', async () => {
|
|
11
35
|
const user = userEvent.setup();
|
|
12
36
|
const { rerender } = render(<LogViewer lines={makeLogLines(100)} height={240} rowHeight={24} />);
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { useEffect, useId, useMemo, useRef, useState, type ReactNode, type UIEvent } from 'react';
|
|
2
|
-
import { Check, Copy, Eye,
|
|
3
|
-
import {
|
|
2
|
+
import { Check, Copy, Eye, X } from '@gntik-ai/icons';
|
|
3
|
+
import {
|
|
4
|
+
IconButton,
|
|
5
|
+
SearchField,
|
|
6
|
+
Switch,
|
|
7
|
+
Toggle,
|
|
8
|
+
ToggleGroup,
|
|
9
|
+
cn,
|
|
10
|
+
copyToClipboard,
|
|
11
|
+
foldText,
|
|
12
|
+
matchRanges,
|
|
13
|
+
useI18n,
|
|
14
|
+
} from '@gntik-ai/ui';
|
|
4
15
|
import { useWrappedLogRows } from './use-wrapped-log-rows';
|
|
5
16
|
import { logLines as defaultLines, type LogLevel, type LogLine } from './fixtures';
|
|
6
17
|
|
|
@@ -27,6 +38,7 @@ export interface LogViewerLabels {
|
|
|
27
38
|
inspect: (timestamp: string) => string;
|
|
28
39
|
copy: (timestamp: string) => string;
|
|
29
40
|
copied: string;
|
|
41
|
+
copyFailed?: string;
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
export interface LogViewerProps {
|
|
@@ -108,12 +120,15 @@ export function LogViewer({
|
|
|
108
120
|
const title = titleProp ?? labels?.title ?? t('logViewer.title');
|
|
109
121
|
const titleId = useId();
|
|
110
122
|
const viewport = useRef<HTMLDivElement>(null);
|
|
123
|
+
const lastFollowTop = useRef<number | null>(null);
|
|
111
124
|
const copyTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
112
125
|
const [levels, setLevels] = useState<string[]>(defaultLevels);
|
|
113
126
|
const [query, setQuery] = useState('');
|
|
114
127
|
const [follow, setFollow] = useState(defaultFollow);
|
|
115
128
|
const [scrollTop, setScrollTop] = useState(0);
|
|
116
|
-
const [
|
|
129
|
+
const [copyResult, setCopyResult] = useState<{ id: string; status: 'copied' | 'failed' } | null>(null);
|
|
130
|
+
const mounted = useRef(true);
|
|
131
|
+
const copyAttempt = useRef(0);
|
|
117
132
|
|
|
118
133
|
const counts = useMemo(() => {
|
|
119
134
|
const c: Record<LogLevel, number> = { debug: 0, info: 0, warn: 0, error: 0 };
|
|
@@ -150,10 +165,31 @@ export function LogViewer({
|
|
|
150
165
|
const rows = visible.slice(start, end);
|
|
151
166
|
|
|
152
167
|
useEffect(() => {
|
|
153
|
-
|
|
154
|
-
|
|
168
|
+
const node = viewport.current;
|
|
169
|
+
if (!follow || !node) {
|
|
170
|
+
lastFollowTop.current = null;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// A measurement can commit before the browser delivers an upward scroll event.
|
|
174
|
+
// Preserve that scroll instead of overwriting it with a new follow position.
|
|
175
|
+
// Account for the browser clamping scrollTop when the content shrinks.
|
|
176
|
+
if (lastFollowTop.current !== null && node.scrollTop < Math.min(lastFollowTop.current, maxScroll) - rowHeight) {
|
|
177
|
+
setScrollTop(node.scrollTop);
|
|
178
|
+
setFollow(false);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
node.scrollTop = maxScroll;
|
|
182
|
+
lastFollowTop.current = node.scrollTop;
|
|
183
|
+
}, [follow, maxScroll, rowHeight]);
|
|
155
184
|
|
|
156
|
-
useEffect(() =>
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
mounted.current = true;
|
|
187
|
+
return () => {
|
|
188
|
+
mounted.current = false;
|
|
189
|
+
copyAttempt.current += 1;
|
|
190
|
+
clearTimeout(copyTimer.current);
|
|
191
|
+
};
|
|
192
|
+
}, []);
|
|
157
193
|
|
|
158
194
|
const onScroll = (event: UIEvent<HTMLDivElement>) => {
|
|
159
195
|
const top = event.currentTarget.scrollTop;
|
|
@@ -161,12 +197,22 @@ export function LogViewer({
|
|
|
161
197
|
if (follow && top < maxScroll - rowHeight) setFollow(false);
|
|
162
198
|
};
|
|
163
199
|
|
|
164
|
-
const copy = (line: LogLine) => {
|
|
165
|
-
void navigator.clipboard?.writeText(lineText(line)).catch(() => undefined);
|
|
166
|
-
onCopyLine?.(line);
|
|
167
|
-
setCopied(line.id);
|
|
200
|
+
const copy = async (line: LogLine) => {
|
|
168
201
|
clearTimeout(copyTimer.current);
|
|
169
|
-
|
|
202
|
+
const current = ++copyAttempt.current;
|
|
203
|
+
let status: 'copied' | 'failed' = 'failed';
|
|
204
|
+
try {
|
|
205
|
+
await copyToClipboard(lineText(line));
|
|
206
|
+
status = 'copied';
|
|
207
|
+
} catch {
|
|
208
|
+
// A denied write must not confirm a copied line.
|
|
209
|
+
}
|
|
210
|
+
if (!mounted.current) return;
|
|
211
|
+
if (current === copyAttempt.current) {
|
|
212
|
+
setCopyResult({ id: line.id, status });
|
|
213
|
+
copyTimer.current = setTimeout(() => setCopyResult(null), 1500);
|
|
214
|
+
}
|
|
215
|
+
if (status === 'copied') onCopyLine?.(line);
|
|
170
216
|
};
|
|
171
217
|
|
|
172
218
|
return (
|
|
@@ -199,12 +245,10 @@ export function LogViewer({
|
|
|
199
245
|
</Toggle>
|
|
200
246
|
))}
|
|
201
247
|
</ToggleGroup>
|
|
202
|
-
<
|
|
248
|
+
<SearchField
|
|
203
249
|
size="sm"
|
|
204
|
-
type="search"
|
|
205
250
|
aria-label={labels?.searchLabel ?? t('logViewer.searchLabel')}
|
|
206
251
|
placeholder={labels?.searchPlaceholder ?? t('logViewer.searchPlaceholder')}
|
|
207
|
-
leadingIcon={Search}
|
|
208
252
|
value={query}
|
|
209
253
|
onValueChange={(v) => setQuery(String(v))}
|
|
210
254
|
className="w-full sm:w-48"
|
|
@@ -224,7 +268,7 @@ export function LogViewer({
|
|
|
224
268
|
aria-live={announceLines && follow ? 'polite' : 'off'}
|
|
225
269
|
tabIndex={0}
|
|
226
270
|
onScroll={onScroll}
|
|
227
|
-
className="relative overflow-auto bg-background font-mono text-[12px] focus-
|
|
271
|
+
className="relative overflow-auto bg-background font-mono text-[12px] focus-ring-inset"
|
|
228
272
|
style={{ height }}
|
|
229
273
|
>
|
|
230
274
|
{visible.length === 0 ? (
|
|
@@ -235,6 +279,7 @@ export function LogViewer({
|
|
|
235
279
|
<div className="relative w-full" style={{ height: total }}>
|
|
236
280
|
{rows.map((line, i) => {
|
|
237
281
|
const lv = LEVEL_STYLE[line.level];
|
|
282
|
+
const status = copyResult?.id === line.id ? copyResult.status : 'idle';
|
|
238
283
|
return (
|
|
239
284
|
<div
|
|
240
285
|
key={line.id}
|
|
@@ -290,15 +335,17 @@ export function LogViewer({
|
|
|
290
335
|
)}
|
|
291
336
|
<IconButton
|
|
292
337
|
size="sm"
|
|
293
|
-
icon={
|
|
338
|
+
icon={status === 'failed' ? X : status === 'copied' ? Check : Copy}
|
|
294
339
|
label={
|
|
295
|
-
|
|
296
|
-
? (labels?.
|
|
297
|
-
:
|
|
340
|
+
status === 'failed'
|
|
341
|
+
? (labels?.copyFailed ?? t('common.copyFailed'))
|
|
342
|
+
: status === 'copied'
|
|
343
|
+
? (labels?.copied ?? t('common.copied'))
|
|
344
|
+
: (labels?.copy?.(line.timestamp) ?? t('logViewer.copy', { timestamp: line.timestamp }))
|
|
298
345
|
}
|
|
299
346
|
onClick={(event) => {
|
|
300
347
|
if (onSelectLine) event.stopPropagation();
|
|
301
|
-
copy(line);
|
|
348
|
+
void copy(line);
|
|
302
349
|
}}
|
|
303
350
|
className="size-6 shrink-0 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"
|
|
304
351
|
/>
|
|
@@ -6,7 +6,7 @@ export const meta: BlockMeta = {
|
|
|
6
6
|
family: 'builders',
|
|
7
7
|
status: 'beta',
|
|
8
8
|
description:
|
|
9
|
-
'Windowed log stream (role="log"): level filter, search with highlighted matches, follow-tail and per-line copy. Renders only the visible rows. Optional wrap (default false) shows full messages in measured, variable-height rows; rowHeight estimates unmeasured rows. Optional labels?: Partial<LogViewerLabels> overrides each built-in label, including per-level chip and filter names through labels.levels. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Copied log text and imported fixtures stay unchanged. See the Catalog labels and Full messages and level names live previews.',
|
|
9
|
+
'Windowed log stream (role="log"): level filter, search with highlighted matches, follow-tail and per-line copy. Renders only the visible rows. Optional wrap (default false) shows full messages in measured, variable-height rows; rowHeight estimates unmeasured rows. Optional labels?: Partial<LogViewerLabels> overrides each built-in label, including per-level chip and filter names through labels.levels. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Copied log text and imported fixtures stay unchanged. See the Catalog labels and Full messages and level names live previews. Copy actions await the clipboard write; denied or unavailable access shows common.copyFailed (overridden by labels.copyFailed), and only a successful write calls onCopyLine. Both results reset after 1500ms. See the Catalog labels live preview.',
|
|
10
10
|
labels: [
|
|
11
11
|
{ key: 'title', type: 'string', state: 'Visible heading and log region name; title prop wins' },
|
|
12
12
|
{ key: 'levelFilter', type: 'string', state: 'Level filter group name' },
|
|
@@ -22,6 +22,7 @@ export const meta: BlockMeta = {
|
|
|
22
22
|
{ key: 'empty', type: 'string', state: 'No matching lines' },
|
|
23
23
|
{ key: 'inspect', type: '(timestamp: string) => string', state: 'Inspect button name when onSelectLine exists' },
|
|
24
24
|
{ key: 'copy', type: '(timestamp: string) => string', state: 'Copy button before copying' },
|
|
25
|
+
{ key: 'copyFailed', type: 'string', state: 'Copy button after a failed write, only on the affected line' },
|
|
25
26
|
{ key: 'copied', type: 'string', state: 'Copy button after copying' },
|
|
26
27
|
] satisfies Array<{ key: keyof LogViewerLabels; type: string; state: string }>,
|
|
27
28
|
uses: ['ToggleGroup', 'Toggle', 'Input', 'Switch', 'IconButton'],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I18nProvider, Stack } from '@gntik-ai/ui';
|
|
1
|
+
import { I18nProvider, Stack, en } from '@gntik-ai/ui';
|
|
2
2
|
import { LogViewer } from '../LogViewer';
|
|
3
3
|
import { makeLogLines } from '../fixtures';
|
|
4
4
|
const lines = makeLogLines(3);
|
|
@@ -12,6 +12,7 @@ export default function Spanish() {
|
|
|
12
12
|
height={100}
|
|
13
13
|
onSelectLine={() => {}}
|
|
14
14
|
labels={{
|
|
15
|
+
copyFailed: en['common.copyFailed'],
|
|
15
16
|
title: 'Application logs',
|
|
16
17
|
levelFilter: 'Severity',
|
|
17
18
|
searchLabel: 'Find log messages',
|
|
@@ -79,7 +79,7 @@ export function ActivityFeed({
|
|
|
79
79
|
<div key={group.key}>
|
|
80
80
|
<GroupTag
|
|
81
81
|
id={headingId}
|
|
82
|
-
className="mb-3 font-mono text-[10.5px] font-medium tracking-[0.12em] text-muted-foreground
|
|
82
|
+
className="mb-3 font-mono text-[10.5px] font-medium tracking-[0.12em] text-muted-foreground label-case"
|
|
83
83
|
>
|
|
84
84
|
{group.label}
|
|
85
85
|
</GroupTag>
|
|
@@ -160,7 +160,7 @@ export function ChartCard<T extends object = CostPoint>({
|
|
|
160
160
|
const { locale } = useI18n();
|
|
161
161
|
return (
|
|
162
162
|
<ChartLocaleProvider locale={locale}>
|
|
163
|
-
<Card className={className}>
|
|
163
|
+
<Card className={cn('@container w-full min-w-0', className)}>
|
|
164
164
|
<CardHeader className="pb-2">
|
|
165
165
|
<CardTitle as={titleAs}>{title}</CardTitle>
|
|
166
166
|
{description && <CardDescription>{description}</CardDescription>}
|
|
@@ -202,7 +202,7 @@ export function ChartCard<T extends object = CostPoint>({
|
|
|
202
202
|
{active.summary.delta && <TrendDelta {...active.summary.delta} />}
|
|
203
203
|
</p>
|
|
204
204
|
)}
|
|
205
|
-
<div className={cn('px-3 pb-4 pt-3 sm:px-4', !footer && 'pb-5')}>
|
|
205
|
+
<div className={cn('px-3 pb-4 pt-3 @sm:px-4', !footer && 'pb-5')}>
|
|
206
206
|
{kind === 'heatmap' ? (
|
|
207
207
|
<Heatmap
|
|
208
208
|
data={data}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InspectorLayout } from '@gntik-ai/ui';
|
|
2
|
+
import { ChartCard } from '../ChartCard';
|
|
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={<ChartCard />}>
|
|
8
|
+
<div className="grid gap-6 overflow-auto p-4">
|
|
9
|
+
<div data-container-slot="default" className="flex min-w-0">
|
|
10
|
+
<ChartCard />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</InspectorLayout>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|