@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,36 @@
|
|
|
1
|
+
import { Mail, Rss } from 'lucide-react';
|
|
2
|
+
import type { SiteFooterColumn, SiteFooterLink, SiteFooterSocialLink } from './SiteFooter';
|
|
3
|
+
|
|
4
|
+
export const sampleFooterColumns: SiteFooterColumn[] = [
|
|
5
|
+
{
|
|
6
|
+
title: 'Product',
|
|
7
|
+
links: [
|
|
8
|
+
{ label: 'Overview', href: '/product' },
|
|
9
|
+
{ label: 'Pricing', href: '/pricing' },
|
|
10
|
+
],
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
title: 'Company',
|
|
14
|
+
links: [
|
|
15
|
+
{ label: 'About', href: '/about' },
|
|
16
|
+
{ label: 'Contact', href: '/contact' },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
title: 'Resources',
|
|
21
|
+
links: [
|
|
22
|
+
{ label: 'Documentation', href: '/docs' },
|
|
23
|
+
{ label: 'Status', href: '/status' },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export const sampleLegalLinks: SiteFooterLink[] = [
|
|
29
|
+
{ label: 'Privacy', href: '/privacy' },
|
|
30
|
+
{ label: 'Terms', href: '/terms' },
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const sampleSocialLinks: SiteFooterSocialLink[] = [
|
|
34
|
+
{ label: 'Email', href: 'mailto:hello@example.com', icon: Mail },
|
|
35
|
+
{ label: 'RSS feed', href: '/feed.xml', icon: Rss },
|
|
36
|
+
];
|
package/src/marketing/index.ts
CHANGED
|
@@ -13,3 +13,9 @@ export type { MarketingAction } from './actions';
|
|
|
13
13
|
export * from './ComparisonTable/ComparisonTable';
|
|
14
14
|
export { meta as comparisonTableMeta } from './ComparisonTable/block.meta';
|
|
15
15
|
export { sampleComparisonPlans, sampleComparisonSections } from './ComparisonTable/fixtures';
|
|
16
|
+
export * from './SiteFooter/SiteFooter';
|
|
17
|
+
export { meta as siteFooterMeta } from './SiteFooter/block.meta';
|
|
18
|
+
export { sampleFooterColumns, sampleLegalLinks, sampleSocialLinks } from './SiteFooter/fixtures';
|
|
19
|
+
export * from './LogoCloud/LogoCloud';
|
|
20
|
+
export { meta as logoCloudMeta } from './LogoCloud/block.meta';
|
|
21
|
+
export { sampleLogos } from './LogoCloud/fixtures';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
4
|
+
import EditableTitle from './examples/EditableTitle';
|
|
5
|
+
|
|
6
|
+
it.each(['dark', 'light', 'high_contrast'])(
|
|
7
|
+
'the editable PageHeader title keeps its name and is axe clean in %s',
|
|
8
|
+
async (theme) => {
|
|
9
|
+
const user = userEvent.setup();
|
|
10
|
+
const { container } = render(
|
|
11
|
+
<div data-theme={theme}>
|
|
12
|
+
<EditableTitle />
|
|
13
|
+
</div>,
|
|
14
|
+
);
|
|
15
|
+
expect(screen.getByRole('heading', { level: 1, name: 'Support agent' })).toBeInTheDocument();
|
|
16
|
+
await expectNoAxeViolations(container);
|
|
17
|
+
await user.click(screen.getByRole('button', { name: 'Support agent' }));
|
|
18
|
+
const input = screen.getByRole('textbox', { name: 'Agent name' });
|
|
19
|
+
expect(input).toHaveFocus();
|
|
20
|
+
await expectNoAxeViolations(container);
|
|
21
|
+
await user.clear(input);
|
|
22
|
+
await user.type(input, 'Billing agent{Enter}');
|
|
23
|
+
expect(screen.getByRole('heading', { level: 1, name: 'Billing agent' })).toBeInTheDocument();
|
|
24
|
+
expect(screen.getByRole('button', { name: 'Billing agent' })).toHaveFocus();
|
|
25
|
+
},
|
|
26
|
+
);
|
|
@@ -58,7 +58,7 @@ export interface PageHeaderProps {
|
|
|
58
58
|
meta?: PageHeaderMetaItem[];
|
|
59
59
|
/**
|
|
60
60
|
* Header actions in visual order. The primary one (first with `variant: 'primary'`, else the
|
|
61
|
-
* last) stays visible
|
|
61
|
+
* last) stays visible in narrow containers; the rest fold into a MoreMenu.
|
|
62
62
|
*/
|
|
63
63
|
actions?: PageChromeAction[];
|
|
64
64
|
/** Resource-level navigation tabs under the header; `null` hides them. */
|
|
@@ -110,7 +110,7 @@ export function PageHeader({
|
|
|
110
110
|
);
|
|
111
111
|
|
|
112
112
|
return (
|
|
113
|
-
<Root className={cn('min-w-0', className)}>
|
|
113
|
+
<Root className={cn('@container w-full min-w-0', className)}>
|
|
114
114
|
{breadcrumbs && breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} maxItems={4} className="mb-2.5" />}
|
|
115
115
|
<div className="flex flex-wrap items-end justify-between gap-4">
|
|
116
116
|
<div className="min-w-0 flex-1">
|
|
@@ -144,8 +144,8 @@ export function PageHeader({
|
|
|
144
144
|
</div>
|
|
145
145
|
{actions.length > 0 && (
|
|
146
146
|
<>
|
|
147
|
-
<div className="hidden shrink-0 items-center gap-2.5
|
|
148
|
-
<div className="flex shrink-0 items-center gap-2
|
|
147
|
+
<div className="hidden shrink-0 items-center gap-2.5 @xl:flex">{actions.map(renderAction)}</div>
|
|
148
|
+
<div className="flex shrink-0 items-center gap-2 @xl:hidden">
|
|
149
149
|
{folded.length > 0 && (
|
|
150
150
|
<MoreMenu items={folded.map(toMenuAction)} label={labels?.moreActions ?? t('pageHeader.moreActions')} />
|
|
151
151
|
)}
|
|
@@ -6,7 +6,7 @@ export const meta: BlockMeta = {
|
|
|
6
6
|
family: 'page-chrome',
|
|
7
7
|
status: 'beta',
|
|
8
8
|
description:
|
|
9
|
-
'Screen header with breadcrumb, title and status, description, meta row, actions that fold into a MoreMenu
|
|
9
|
+
'Screen header with breadcrumb, title and status, description, meta row, actions that fold into a MoreMenu in narrow containers, and optional navigation tabs. titleRef targets the h1 for titleRef.current.focus(), adding tabIndex=-1 only when supplied so the title stays outside the Tab order. In a StatusLayout heading slot use as="div" and disable breadcrumb, meta, tabs, actions, status and description fixtures; the slot supplies the page’s only h1. The tablist name follows I18nProvider (en/es); the Spanish preview keeps caller content unchanged. Optional labels?: Partial<PageHeaderLabels> overrides each built-in label. Explicit content props win over labels, then I18nProvider (en/es); no provider keeps English. Imported fixtures and machine data stay unchanged. See the Catalog labels live preview. wrapTitle?: boolean (default false) wraps the full title, including long words, while preserving titleRef focus behavior. The default title remains truncated. See the Spanish live preview for a wrapping title.',
|
|
10
10
|
labels: [
|
|
11
11
|
{ key: 'title', type: 'string', state: 'Heading; explicit title prop wins, including null' },
|
|
12
12
|
{ key: 'description', type: 'string', state: 'Description; explicit description prop wins, including null' },
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InspectorLayout } from '@gntik-ai/ui';
|
|
2
|
+
import { PageHeader } from '../PageHeader';
|
|
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={<PageHeader as="div" />}>
|
|
8
|
+
<div className="grid gap-6 overflow-auto p-4">
|
|
9
|
+
<div data-container-slot="default" className="flex min-w-0">
|
|
10
|
+
<PageHeader as="div" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</InspectorLayout>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EditableText, useI18n } from '@gntik-ai/ui';
|
|
2
|
+
import { PageHeader } from '../PageHeader';
|
|
3
|
+
|
|
4
|
+
export default function EditableTitle() {
|
|
5
|
+
const { t } = useI18n();
|
|
6
|
+
return (
|
|
7
|
+
<PageHeader
|
|
8
|
+
title={
|
|
9
|
+
<EditableText
|
|
10
|
+
defaultValue={t('editableText.example.supportAgent')}
|
|
11
|
+
label={t('editableText.example.agentName')}
|
|
12
|
+
onSave={() => {}}
|
|
13
|
+
/>
|
|
14
|
+
}
|
|
15
|
+
breadcrumbs={null}
|
|
16
|
+
description={null}
|
|
17
|
+
status=""
|
|
18
|
+
meta={[]}
|
|
19
|
+
actions={[]}
|
|
20
|
+
tabs={null}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -45,7 +45,7 @@ export function StickyActionBar({
|
|
|
45
45
|
return (
|
|
46
46
|
<section
|
|
47
47
|
aria-label={ariaLabel}
|
|
48
|
-
className={cn('sticky bottom-0 z-
|
|
48
|
+
className={cn('sticky bottom-0 z-docked border-t border-border bg-card px-4 py-3 shadow-sm sm:px-6', className)}
|
|
49
49
|
>
|
|
50
50
|
<div className="mx-auto flex max-w-5xl flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
51
51
|
<p role="status" className="flex items-center gap-2 text-[13px] text-foreground">
|
|
@@ -2,6 +2,7 @@ import { useId, useMemo } from 'react';
|
|
|
2
2
|
import { Badge, EmptyState, cn, useI18n } from '@gntik-ai/ui';
|
|
3
3
|
import { CalendarDays, ChevronRight, Clock } from '@gntik-ai/icons';
|
|
4
4
|
import { useSchedulingClock } from '../shared/useSchedulingClock';
|
|
5
|
+
import { TimeZoneLabel } from '../shared/CalendarHeader';
|
|
5
6
|
import { EventTile } from '../shared/EventTile';
|
|
6
7
|
import { addDays, dayKey, formatDay, formatRange, sameDay, type HourCycle } from '../shared/dates';
|
|
7
8
|
import { defaultEventKinds, groupByDay, kindOf, TONE, type EventKind, type ScheduleEvent } from '../shared/events';
|
|
@@ -9,6 +10,8 @@ import { sampleEvents, sampleToday } from '../shared/fixtures';
|
|
|
9
10
|
|
|
10
11
|
export interface AgendaListProps {
|
|
11
12
|
events?: ScheduleEvent[];
|
|
13
|
+
/** Display time zone; defaults to the I18nProvider zone (system outside a provider). */
|
|
14
|
+
timeZone?: string;
|
|
12
15
|
/** Clock used for event ranges; defaults to the provider or runtime locale. */
|
|
13
16
|
hourCycle?: HourCycle;
|
|
14
17
|
/** The app's "today": labels the Today/Tomorrow groups. */
|
|
@@ -33,6 +36,7 @@ export interface AgendaListProps {
|
|
|
33
36
|
/** Upcoming scheduled work grouped by day, each row with a kind tile, time range and location. */
|
|
34
37
|
export function AgendaList({
|
|
35
38
|
events = sampleEvents,
|
|
39
|
+
timeZone: timeZoneProp,
|
|
36
40
|
hourCycle: hourCycleProp,
|
|
37
41
|
today = sampleToday,
|
|
38
42
|
from,
|
|
@@ -46,7 +50,8 @@ export function AgendaList({
|
|
|
46
50
|
titleAs: TitleTag = 'h3',
|
|
47
51
|
className,
|
|
48
52
|
}: AgendaListProps) {
|
|
49
|
-
const { t, locale } = useI18n();
|
|
53
|
+
const { t, locale, timeZone: providerZone } = useI18n();
|
|
54
|
+
const timeZone = timeZoneProp ?? providerZone;
|
|
50
55
|
const clock = useSchedulingClock(hourCycleProp);
|
|
51
56
|
const title = titleProp ?? t('calendar.agenda');
|
|
52
57
|
const emptyTitle = emptyTitleProp ?? t('calendar.emptyTitle');
|
|
@@ -55,23 +60,42 @@ export function AgendaList({
|
|
|
55
60
|
const uid = useId();
|
|
56
61
|
const start = from === undefined ? today : from;
|
|
57
62
|
const groups = useMemo(() => {
|
|
58
|
-
const first = start ? dayKey(start) : null;
|
|
59
|
-
const last = start && days != null ? dayKey(addDays(start, days - 1)) : null;
|
|
60
|
-
return [...groupByDay(events).entries()]
|
|
63
|
+
const first = start ? dayKey(start, timeZone) : null;
|
|
64
|
+
const last = start && days != null ? dayKey(addDays(start, days - 1, timeZone), timeZone) : null;
|
|
65
|
+
return [...groupByDay(events, timeZone).entries()]
|
|
61
66
|
.filter(([key]) => (first == null || key >= first) && (last == null || key <= last))
|
|
62
67
|
.sort(([a], [b]) => a.localeCompare(b));
|
|
63
|
-
}, [events, start, days]);
|
|
68
|
+
}, [events, start, days, timeZone]);
|
|
64
69
|
|
|
65
70
|
const dayLabel = (d: Date) => {
|
|
66
|
-
if (sameDay(d, today)) return `${t('calendar.today')} · ${formatDay(d, locale)}`;
|
|
67
|
-
if (sameDay(d, addDays(today, 1
|
|
68
|
-
|
|
71
|
+
if (sameDay(d, today, timeZone)) return `${t('calendar.today')} · ${formatDay(d, locale, timeZone)}`;
|
|
72
|
+
if (sameDay(d, addDays(today, 1, timeZone), timeZone))
|
|
73
|
+
return `${t('calendar.tomorrow')} · ${formatDay(d, locale, timeZone)}`;
|
|
74
|
+
return formatDay(d, locale, timeZone);
|
|
69
75
|
};
|
|
70
76
|
|
|
71
77
|
return (
|
|
72
|
-
<section
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
<section
|
|
79
|
+
aria-label={timeZone === 'system' ? title : undefined}
|
|
80
|
+
aria-labelledby={timeZone === 'system' ? undefined : `${uid}-title ${uid}-zone`}
|
|
81
|
+
className={cn('overflow-hidden rounded-xl border border-border bg-card', className)}
|
|
82
|
+
>
|
|
83
|
+
<div
|
|
84
|
+
className={cn(
|
|
85
|
+
'flex items-center justify-between gap-3 border-b border-border px-4 py-3 sm:px-5',
|
|
86
|
+
timeZone !== 'system' && 'flex-wrap',
|
|
87
|
+
)}
|
|
88
|
+
>
|
|
89
|
+
{timeZone === 'system' ? (
|
|
90
|
+
<TitleTag className="text-[15px] font-semibold tracking-tight text-foreground">{title}</TitleTag>
|
|
91
|
+
) : (
|
|
92
|
+
<div className="min-w-0">
|
|
93
|
+
<TitleTag id={`${uid}-title`} className="text-[15px] font-semibold tracking-tight text-foreground">
|
|
94
|
+
{title}
|
|
95
|
+
</TitleTag>
|
|
96
|
+
<TimeZoneLabel id={`${uid}-zone`} timeZone={timeZone} referenceDate={start ?? today} />
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
75
99
|
<span className="font-mono text-[11px] text-muted-foreground">
|
|
76
100
|
{groups.reduce((n, [, list]) => n + list.length, 0)} scheduled
|
|
77
101
|
</span>
|
|
@@ -90,7 +114,7 @@ export function AgendaList({
|
|
|
90
114
|
tabIndex={maxHeight ? 0 : undefined}
|
|
91
115
|
role={maxHeight ? 'region' : undefined}
|
|
92
116
|
aria-label={maxHeight ? `${title} list` : undefined}
|
|
93
|
-
className="overflow-y-auto focus-
|
|
117
|
+
className="overflow-y-auto focus-ring-inset"
|
|
94
118
|
>
|
|
95
119
|
{groups.map(([key, list]) => {
|
|
96
120
|
const first = list[0];
|
|
@@ -100,7 +124,7 @@ export function AgendaList({
|
|
|
100
124
|
<div key={key}>
|
|
101
125
|
<SubTag
|
|
102
126
|
id={headingId}
|
|
103
|
-
className="border-b border-border bg-secondary/30 px-4 py-2 font-mono text-[11px] tracking-wide text-muted-foreground
|
|
127
|
+
className="border-b border-border bg-secondary/30 px-4 py-2 font-mono text-[11px] tracking-wide text-muted-foreground label-case sm:px-5"
|
|
104
128
|
>
|
|
105
129
|
{dayLabel(first.start)}
|
|
106
130
|
</SubTag>
|
|
@@ -110,7 +134,7 @@ export function AgendaList({
|
|
|
110
134
|
>
|
|
111
135
|
{list.map((event) => {
|
|
112
136
|
const kind = kindOf(event, kinds);
|
|
113
|
-
const range = formatRange(event.start, event.end, clock.locale, clock.hourCycle);
|
|
137
|
+
const range = formatRange(event.start, event.end, clock.locale, clock.hourCycle, timeZone);
|
|
114
138
|
const content = (
|
|
115
139
|
<>
|
|
116
140
|
<EventTile kind={kind} />
|
|
@@ -143,7 +167,7 @@ export function AgendaList({
|
|
|
143
167
|
onClick={() => onEventClick(event)}
|
|
144
168
|
className={cn(
|
|
145
169
|
row,
|
|
146
|
-
'group transition-colors hover:bg-accent/30 focus-
|
|
170
|
+
'group transition-colors hover:bg-accent/30 focus-ring-inset motion-reduce:transition-none',
|
|
147
171
|
)}
|
|
148
172
|
>
|
|
149
173
|
{content}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import TimeZoneExample from './examples/TimeZone';
|
|
2
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
3
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
4
|
+
import { render, screen, within } from '@testing-library/react';
|
|
5
|
+
import { AgendaList } from './AgendaList';
|
|
6
|
+
|
|
7
|
+
it('groups, filters and formats on the provider clock instead of the Madrid runtime', () => {
|
|
8
|
+
vi.stubEnv('TZ', 'Europe/Madrid');
|
|
9
|
+
try {
|
|
10
|
+
render(
|
|
11
|
+
<I18nProvider locale="en-US" timeZone="America/New_York">
|
|
12
|
+
<AgendaList
|
|
13
|
+
days={1}
|
|
14
|
+
today={new Date('2026-04-16T01:00:00Z')}
|
|
15
|
+
events={[
|
|
16
|
+
{
|
|
17
|
+
id: 'late',
|
|
18
|
+
title: 'Late run',
|
|
19
|
+
start: new Date('2026-04-16T01:00:00Z'),
|
|
20
|
+
end: new Date('2026-04-16T02:00:00Z'),
|
|
21
|
+
},
|
|
22
|
+
]}
|
|
23
|
+
/>
|
|
24
|
+
</I18nProvider>,
|
|
25
|
+
);
|
|
26
|
+
const group = screen.getByRole('list', { name: 'Today · Wednesday, April 15' });
|
|
27
|
+
expect(within(group).getByText('9:00 PM–10:00 PM')).toBeInTheDocument();
|
|
28
|
+
expect(within(group).getByText('Late run')).toBeInTheDocument();
|
|
29
|
+
expect(screen.getByText('Times in America/New_York (EDT)')).toBeInTheDocument();
|
|
30
|
+
} finally {
|
|
31
|
+
vi.unstubAllEnvs();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('has no axe violations in the display-zone example', async () => {
|
|
36
|
+
const { container } = render(<TimeZoneExample />);
|
|
37
|
+
await expectNoAxeViolations(container);
|
|
38
|
+
});
|
|
@@ -5,6 +5,6 @@ export const meta: BlockMeta = {
|
|
|
5
5
|
family: 'scheduling',
|
|
6
6
|
status: 'beta',
|
|
7
7
|
description:
|
|
8
|
-
'Upcoming scheduled work grouped by day (Today/Tomorrow labels), each row with a kind tile, locale-formatted time range, location and kind badge; empty state included. hourCycle overrides the provider/runtime clock. Locale examples show en-US, es-ES, then en-US with the 24-hour override.',
|
|
8
|
+
'Upcoming scheduled work grouped by day (Today/Tomorrow labels), each row with a kind tile, locale-formatted time range, location and kind badge; empty state included. hourCycle overrides the provider/runtime clock. timeZone defaults to I18nProvider (system when unset); TimeZone examples demonstrate UTC, an explicit New York override and a Spanish Madrid provider. Use the same zone on server and client. Locale examples show en-US, es-ES, then en-US with the 24-hour override.',
|
|
9
9
|
uses: ['Badge', 'EmptyState'],
|
|
10
10
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { AgendaList } from '../AgendaList';
|
|
3
|
+
|
|
4
|
+
const today = new Date('2026-04-15T13:00:00Z');
|
|
5
|
+
const events = [
|
|
6
|
+
{
|
|
7
|
+
id: 'morning',
|
|
8
|
+
title: 'Morning run',
|
|
9
|
+
start: new Date('2026-04-15T13:00:00Z'),
|
|
10
|
+
end: new Date('2026-04-15T14:00:00Z'),
|
|
11
|
+
},
|
|
12
|
+
{ id: 'late', title: 'Late run', start: new Date('2026-04-15T23:30:00Z'), end: new Date('2026-04-16T00:30:00Z') },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
/** UTC provider default, New York prop override, then a Spanish Madrid provider. */
|
|
16
|
+
export default function TimeZone() {
|
|
17
|
+
return (
|
|
18
|
+
<div className="space-y-6">
|
|
19
|
+
<I18nProvider locale="en-US" timeZone="UTC">
|
|
20
|
+
<AgendaList today={today} events={events} />
|
|
21
|
+
<AgendaList today={today} events={events} timeZone="America/New_York" />
|
|
22
|
+
</I18nProvider>
|
|
23
|
+
<I18nProvider locale="es-ES" timeZone="Europe/Madrid">
|
|
24
|
+
<AgendaList today={today} events={events} />
|
|
25
|
+
</I18nProvider>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useEffect, useId, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';
|
|
2
|
-
import { cn, useI18n, localeWeekStart, type WeekDay } from '@gntik-ai/ui';
|
|
2
|
+
import { cn, useI18n, zonedParts, localeWeekStart, type WeekDay } from '@gntik-ai/ui';
|
|
3
3
|
import { useSchedulingClock } from '../shared/useSchedulingClock';
|
|
4
4
|
import { CalendarHeader } from '../shared/CalendarHeader';
|
|
5
5
|
import {
|
|
6
6
|
type HourCycle,
|
|
7
|
+
weekday,
|
|
7
8
|
addDays,
|
|
8
9
|
addMonths,
|
|
9
10
|
dayKey,
|
|
@@ -24,6 +25,8 @@ import { sampleEvents, sampleToday } from '../shared/fixtures';
|
|
|
24
25
|
|
|
25
26
|
export interface MonthCalendarProps {
|
|
26
27
|
events?: ScheduleEvent[];
|
|
28
|
+
/** Display time zone; defaults to the I18nProvider zone (system outside a provider). */
|
|
29
|
+
timeZone?: string;
|
|
27
30
|
/** Clock used for event times; defaults to the provider or runtime locale. */
|
|
28
31
|
hourCycle?: HourCycle;
|
|
29
32
|
/** First weekday; defaults to the provider or runtime locale. */
|
|
@@ -53,6 +56,7 @@ export interface MonthCalendarProps {
|
|
|
53
56
|
*/
|
|
54
57
|
export function MonthCalendar({
|
|
55
58
|
events = sampleEvents,
|
|
59
|
+
timeZone: timeZoneProp,
|
|
56
60
|
hourCycle: hourCycleProp,
|
|
57
61
|
weekStartsOn: weekStartsOnProp,
|
|
58
62
|
today = sampleToday,
|
|
@@ -65,56 +69,61 @@ export function MonthCalendar({
|
|
|
65
69
|
actions,
|
|
66
70
|
className,
|
|
67
71
|
}: MonthCalendarProps) {
|
|
68
|
-
const { t, locale, dir } = useI18n();
|
|
72
|
+
const { t, locale, dir, timeZone: providerZone } = useI18n();
|
|
73
|
+
const timeZone = timeZoneProp ?? providerZone;
|
|
69
74
|
const clock = useSchedulingClock(hourCycleProp);
|
|
70
75
|
const weekStartsOn = weekStartsOnProp ?? localeWeekStart(clock.locale);
|
|
71
76
|
const titleId = useId();
|
|
72
|
-
const [selected, setSelected] = useState<Date>(() => startOfDay(defaultSelected ?? today));
|
|
73
|
-
const [focused, setFocused] = useState<Date>(() => startOfDay(defaultSelected ?? defaultMonth ?? today));
|
|
74
|
-
const [month, setMonth] = useState<Date>(() => startOfMonth(defaultMonth ?? defaultSelected ?? today));
|
|
77
|
+
const [selected, setSelected] = useState<Date>(() => startOfDay(defaultSelected ?? today, timeZone));
|
|
78
|
+
const [focused, setFocused] = useState<Date>(() => startOfDay(defaultSelected ?? defaultMonth ?? today, timeZone));
|
|
79
|
+
const [month, setMonth] = useState<Date>(() => startOfMonth(defaultMonth ?? defaultSelected ?? today, timeZone));
|
|
75
80
|
const gridRef = useRef<HTMLDivElement>(null);
|
|
76
81
|
const moveFocus = useRef(false);
|
|
77
|
-
const byDay = useMemo(() => groupByDay(events), [events]);
|
|
78
|
-
const weeks = monthGrid(month, weekStartsOn);
|
|
82
|
+
const byDay = useMemo(() => groupByDay(events, timeZone), [events, timeZone]);
|
|
83
|
+
const weeks = monthGrid(month, weekStartsOn, timeZone);
|
|
79
84
|
const weekend = weekendDays(clock.locale);
|
|
80
85
|
// The roving tab stop stays inside the visible month.
|
|
81
|
-
const tabStop = sameMonth(focused, month
|
|
86
|
+
const tabStop = sameMonth(focused, month, timeZone)
|
|
87
|
+
? focused
|
|
88
|
+
: sameMonth(selected, month, timeZone)
|
|
89
|
+
? selected
|
|
90
|
+
: month;
|
|
82
91
|
|
|
83
92
|
useEffect(() => {
|
|
84
93
|
if (!moveFocus.current) return;
|
|
85
94
|
moveFocus.current = false;
|
|
86
|
-
gridRef.current?.querySelector<HTMLElement>(`[data-date="${dayKey(focused)}"]`)?.focus();
|
|
87
|
-
}, [focused]);
|
|
95
|
+
gridRef.current?.querySelector<HTMLElement>(`[data-date="${dayKey(focused, timeZone)}"]`)?.focus();
|
|
96
|
+
}, [focused, timeZone]);
|
|
88
97
|
|
|
89
98
|
const showMonth = (next: Date) => {
|
|
90
|
-
const first = startOfMonth(next);
|
|
99
|
+
const first = startOfMonth(next, timeZone);
|
|
91
100
|
setMonth(first);
|
|
92
101
|
onMonthChange?.(first);
|
|
93
102
|
};
|
|
94
103
|
|
|
95
104
|
const go = (date: Date) => {
|
|
96
105
|
setFocused(date);
|
|
97
|
-
if (!sameMonth(date, month)) showMonth(date);
|
|
106
|
+
if (!sameMonth(date, month, timeZone)) showMonth(date);
|
|
98
107
|
moveFocus.current = true;
|
|
99
108
|
};
|
|
100
109
|
|
|
101
110
|
const select = (date: Date) => {
|
|
102
111
|
setSelected(date);
|
|
103
112
|
setFocused(date);
|
|
104
|
-
onSelectDate?.(date, byDay.get(dayKey(date)) ?? []);
|
|
113
|
+
onSelectDate?.(date, byDay.get(dayKey(date, timeZone)) ?? []);
|
|
105
114
|
};
|
|
106
115
|
|
|
107
116
|
const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, date: Date) => {
|
|
108
|
-
const weekStart = startOfWeek(date, weekStartsOn);
|
|
117
|
+
const weekStart = startOfWeek(date, weekStartsOn, timeZone);
|
|
109
118
|
const map: Record<string, () => Date> = {
|
|
110
|
-
ArrowLeft: () => addDays(date, dir === 'rtl' ? 1 : -1),
|
|
111
|
-
ArrowRight: () => addDays(date, dir === 'rtl' ? -1 : 1),
|
|
112
|
-
ArrowUp: () => addDays(date, -7),
|
|
113
|
-
ArrowDown: () => addDays(date, 7),
|
|
119
|
+
ArrowLeft: () => addDays(date, dir === 'rtl' ? 1 : -1, timeZone),
|
|
120
|
+
ArrowRight: () => addDays(date, dir === 'rtl' ? -1 : 1, timeZone),
|
|
121
|
+
ArrowUp: () => addDays(date, -7, timeZone),
|
|
122
|
+
ArrowDown: () => addDays(date, 7, timeZone),
|
|
114
123
|
Home: () => weekStart,
|
|
115
|
-
End: () => addDays(weekStart, 6),
|
|
116
|
-
PageUp: () =>
|
|
117
|
-
PageDown: () =>
|
|
124
|
+
End: () => addDays(weekStart, 6, timeZone),
|
|
125
|
+
PageUp: () => addDays(addMonths(date, -1, timeZone), Math.min(zonedParts(date, timeZone).day, 28) - 1, timeZone),
|
|
126
|
+
PageDown: () => addDays(addMonths(date, 1, timeZone), Math.min(zonedParts(date, timeZone).day, 28) - 1, timeZone),
|
|
118
127
|
};
|
|
119
128
|
const next = map[event.key];
|
|
120
129
|
if (!next) return;
|
|
@@ -125,15 +134,17 @@ export function MonthCalendar({
|
|
|
125
134
|
return (
|
|
126
135
|
<div className={cn('overflow-hidden rounded-xl border border-border bg-card', className)}>
|
|
127
136
|
<CalendarHeader
|
|
137
|
+
timeZone={timeZone}
|
|
138
|
+
referenceDate={month}
|
|
128
139
|
titleId={titleId}
|
|
129
|
-
title={formatMonth(month, locale)}
|
|
140
|
+
title={formatMonth(month, locale, timeZone)}
|
|
130
141
|
prevLabel={t('calendar.previousMonth')}
|
|
131
142
|
nextLabel={t('calendar.nextMonth')}
|
|
132
|
-
onPrev={() => showMonth(addMonths(month, -1))}
|
|
133
|
-
onNext={() => showMonth(addMonths(month, 1))}
|
|
143
|
+
onPrev={() => showMonth(addMonths(month, -1, timeZone))}
|
|
144
|
+
onNext={() => showMonth(addMonths(month, 1, timeZone))}
|
|
134
145
|
onToday={() => {
|
|
135
146
|
showMonth(today);
|
|
136
|
-
setFocused(startOfDay(today));
|
|
147
|
+
setFocused(startOfDay(today, timeZone));
|
|
137
148
|
}}
|
|
138
149
|
actions={actions}
|
|
139
150
|
/>
|
|
@@ -141,43 +152,43 @@ export function MonthCalendar({
|
|
|
141
152
|
<div role="row" className="grid grid-cols-7 border-b border-border bg-secondary/30">
|
|
142
153
|
{(weeks[0] ?? []).map((day) => (
|
|
143
154
|
<div
|
|
144
|
-
key={day
|
|
155
|
+
key={weekday(day, timeZone)}
|
|
145
156
|
role="columnheader"
|
|
146
|
-
aria-label={formatWeekday(day, locale, 'long')}
|
|
147
|
-
className="py-2 text-center text-[11px] font-medium tracking-wide text-muted-foreground
|
|
157
|
+
aria-label={formatWeekday(day, locale, 'long', timeZone)}
|
|
158
|
+
className="py-2 text-center text-[11px] font-medium tracking-wide text-muted-foreground label-case"
|
|
148
159
|
>
|
|
149
|
-
{formatWeekday(day, locale)}
|
|
160
|
+
{formatWeekday(day, locale, 'short', timeZone)}
|
|
150
161
|
</div>
|
|
151
162
|
))}
|
|
152
163
|
</div>
|
|
153
164
|
{weeks.map((week) => (
|
|
154
|
-
<div key={dayKey(week[0] ?? month)} role="row" className="grid grid-cols-7">
|
|
165
|
+
<div key={dayKey(week[0] ?? month, timeZone)} role="row" className="grid grid-cols-7">
|
|
155
166
|
{week.map((date) => {
|
|
156
|
-
const key = dayKey(date);
|
|
167
|
+
const key = dayKey(date, timeZone);
|
|
157
168
|
const list = byDay.get(key) ?? [];
|
|
158
|
-
const inMonth = sameMonth(date, month);
|
|
159
|
-
const isToday = sameDay(date, today);
|
|
160
|
-
const isSelected = sameDay(date, selected);
|
|
169
|
+
const inMonth = sameMonth(date, month, timeZone);
|
|
170
|
+
const isToday = sameDay(date, today, timeZone);
|
|
171
|
+
const isSelected = sameDay(date, selected, timeZone);
|
|
161
172
|
const extra = list.length - maxEventsPerDay;
|
|
162
173
|
return (
|
|
163
174
|
<div
|
|
164
175
|
key={key}
|
|
165
176
|
role="gridcell"
|
|
166
|
-
data-weekend={weekend.includes(date
|
|
177
|
+
data-weekend={weekend.includes(weekday(date, timeZone)) ? '' : undefined}
|
|
167
178
|
aria-selected={isSelected}
|
|
168
179
|
className="min-w-0 border-e border-b border-border/70 [&:nth-child(7)]:border-e-0"
|
|
169
180
|
>
|
|
170
181
|
<button
|
|
171
182
|
type="button"
|
|
172
183
|
data-date={key}
|
|
173
|
-
tabIndex={sameDay(date, tabStop) ? 0 : -1}
|
|
174
|
-
aria-label={`${formatFullDate(date, locale)}${list.length ? `, ${t('calendar.events', { count: list.length })}` : ''}`}
|
|
184
|
+
tabIndex={sameDay(date, tabStop, timeZone) ? 0 : -1}
|
|
185
|
+
aria-label={`${formatFullDate(date, locale, timeZone)}${list.length ? `, ${t('calendar.events', { count: list.length })}` : ''}`}
|
|
175
186
|
aria-current={isToday ? 'date' : undefined}
|
|
176
187
|
onClick={() => select(date)}
|
|
177
188
|
onKeyDown={(e) => onKeyDown(e, date)}
|
|
178
189
|
className={cn(
|
|
179
190
|
'flex h-full min-h-14 w-full flex-col items-stretch p-1.5 text-start transition-colors motion-reduce:transition-none sm:min-h-[92px] sm:p-2',
|
|
180
|
-
'hover:bg-accent/30 focus-
|
|
191
|
+
'hover:bg-accent/30 focus-ring-inset',
|
|
181
192
|
inMonth ? 'bg-card' : 'bg-secondary/20',
|
|
182
193
|
)}
|
|
183
194
|
>
|
|
@@ -194,7 +205,7 @@ export function MonthCalendar({
|
|
|
194
205
|
: 'text-muted-foreground',
|
|
195
206
|
)}
|
|
196
207
|
>
|
|
197
|
-
{date.
|
|
208
|
+
{zonedParts(date, timeZone).day}
|
|
198
209
|
</span>
|
|
199
210
|
{isSelected && !isToday && <span aria-hidden className="size-1.5 rounded-full bg-primary" />}
|
|
200
211
|
</span>
|
|
@@ -211,7 +222,7 @@ export function MonthCalendar({
|
|
|
211
222
|
<span className={cn('size-1.5 shrink-0 rounded-full', TONE[kindOf(e, kinds).tone].dot)} />
|
|
212
223
|
<span className="truncate text-[11px] text-foreground/80">{e.title}</span>
|
|
213
224
|
<span className="ms-auto hidden shrink-0 font-mono text-[10px] text-muted-foreground xl:block">
|
|
214
|
-
{formatTime(e.start, clock.locale, clock.hourCycle)}
|
|
225
|
+
{formatTime(e.start, clock.locale, clock.hourCycle, timeZone)}
|
|
215
226
|
</span>
|
|
216
227
|
</span>
|
|
217
228
|
))}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import TimeZoneExample from './examples/TimeZone';
|
|
2
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
3
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
4
|
+
import { render, screen, within } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
import { MonthCalendar } from './MonthCalendar';
|
|
7
|
+
|
|
8
|
+
const event = {
|
|
9
|
+
id: 'late',
|
|
10
|
+
title: 'Late run',
|
|
11
|
+
start: new Date('2026-04-15T23:30:00Z'),
|
|
12
|
+
end: new Date('2026-04-16T00:00:00Z'),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe('MonthCalendar display zone', () => {
|
|
16
|
+
beforeAll(() => vi.stubEnv('TZ', 'Europe/Madrid'));
|
|
17
|
+
afterAll(() => vi.unstubAllEnvs());
|
|
18
|
+
it('buckets UTC events on April 15 on a Madrid machine, and navigates UTC days', async () => {
|
|
19
|
+
const onSelectDate = vi.fn();
|
|
20
|
+
render(
|
|
21
|
+
<I18nProvider locale="en-US" timeZone="Europe/Madrid">
|
|
22
|
+
<MonthCalendar
|
|
23
|
+
timeZone="UTC"
|
|
24
|
+
events={[event]}
|
|
25
|
+
today={new Date('2026-04-15T23:30:00Z')}
|
|
26
|
+
onSelectDate={onSelectDate}
|
|
27
|
+
/>
|
|
28
|
+
</I18nProvider>,
|
|
29
|
+
);
|
|
30
|
+
const day = screen.getByRole('button', { name: 'Wednesday, April 15, 2026, 1 event' });
|
|
31
|
+
expect(within(day).getByText('Late run')).toBeInTheDocument();
|
|
32
|
+
expect(day).toHaveAttribute('aria-current', 'date');
|
|
33
|
+
expect(within(day).getByText('11:30 PM')).toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('Times in UTC')).toBeInTheDocument();
|
|
35
|
+
day.focus();
|
|
36
|
+
await userEvent.setup().keyboard('{ArrowRight}{Enter}');
|
|
37
|
+
expect(onSelectDate).toHaveBeenCalledWith(new Date('2026-04-16T00:00:00Z'), []);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('has no axe violations in the display-zone example', async () => {
|
|
42
|
+
const { container } = render(<TimeZoneExample />);
|
|
43
|
+
await expectNoAxeViolations(container);
|
|
44
|
+
});
|
|
@@ -5,6 +5,6 @@ export const meta: BlockMeta = {
|
|
|
5
5
|
family: 'scheduling',
|
|
6
6
|
status: 'beta',
|
|
7
7
|
description:
|
|
8
|
-
'Locale-first month grid of scheduled work with per-day event lines, today/selected states, month navigation and full grid keyboard support. weekStartsOn and hourCycle override provider/runtime defaults; data-weekend marks locale weekends without styling. Locale examples show en-US, es-ES, then en-US with Monday-first and 24-hour overrides.',
|
|
8
|
+
'Locale-first month grid of scheduled work with per-day event lines, today/selected states, month navigation and full grid keyboard support. weekStartsOn and hourCycle override provider/runtime defaults; data-weekend marks locale weekends without styling. timeZone defaults to I18nProvider (system when unset); TimeZone examples demonstrate UTC, an explicit New York override and a Spanish Madrid provider. Use the same zone on server and client. Locale examples show en-US, es-ES, then en-US with Monday-first and 24-hour overrides.',
|
|
9
9
|
uses: ['Button', 'IconButton'],
|
|
10
10
|
};
|