@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,28 @@
|
|
|
1
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { MonthCalendar } from '../MonthCalendar';
|
|
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
|
+
<MonthCalendar today={today} events={events} />
|
|
21
|
+
<MonthCalendar today={today} events={events} timeZone="America/New_York" />
|
|
22
|
+
</I18nProvider>
|
|
23
|
+
<I18nProvider locale="es-ES" timeZone="Europe/Madrid">
|
|
24
|
+
<MonthCalendar today={today} events={events} />
|
|
25
|
+
</I18nProvider>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { useEffect, useId, useMemo, useRef, useState, 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
|
formatHour,
|
|
8
9
|
addDays,
|
|
9
10
|
dayKey,
|
|
@@ -23,6 +24,8 @@ import { sampleEvents, sampleToday } from '../shared/fixtures';
|
|
|
23
24
|
|
|
24
25
|
export interface WeekCalendarProps {
|
|
25
26
|
events?: ScheduleEvent[];
|
|
27
|
+
/** Display time zone; defaults to the I18nProvider zone (system outside a provider). */
|
|
28
|
+
timeZone?: string;
|
|
26
29
|
/** First weekday; defaults to the provider or runtime locale. */
|
|
27
30
|
weekStartsOn?: WeekDay;
|
|
28
31
|
/** Clock used for events and hour labels; defaults to the provider or runtime locale. */
|
|
@@ -59,7 +62,7 @@ interface Placed {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
/** Side-by-side lanes for overlapping events within one day. */
|
|
62
|
-
function layoutDay(list: readonly ScheduleEvent[], hourHeight: number): Placed[] {
|
|
65
|
+
function layoutDay(list: readonly ScheduleEvent[], hourHeight: number, timeZone: string): Placed[] {
|
|
63
66
|
const placed: Placed[] = [];
|
|
64
67
|
let cluster: Placed[] = [];
|
|
65
68
|
let clusterEnd = -1;
|
|
@@ -70,8 +73,8 @@ function layoutDay(list: readonly ScheduleEvent[], hourHeight: number): Placed[]
|
|
|
70
73
|
laneEnds = [];
|
|
71
74
|
};
|
|
72
75
|
for (const event of list) {
|
|
73
|
-
const start = hourOf(event.start);
|
|
74
|
-
const end = Math.max(sameDay(event.start, event.end) ? hourOf(event.end) : 24, start + 0.25);
|
|
76
|
+
const start = hourOf(event.start, timeZone);
|
|
77
|
+
const end = Math.max(sameDay(event.start, event.end, timeZone) ? hourOf(event.end, timeZone) : 24, start + 0.25);
|
|
75
78
|
if (start >= clusterEnd) close();
|
|
76
79
|
let lane = laneEnds.findIndex((e) => e <= start);
|
|
77
80
|
if (lane === -1) {
|
|
@@ -96,6 +99,7 @@ function layoutDay(list: readonly ScheduleEvent[], hourHeight: number): Placed[]
|
|
|
96
99
|
/** Week view: seven day columns over a scrolling 24-hour time grid, with a "now" line. */
|
|
97
100
|
export function WeekCalendar({
|
|
98
101
|
events = sampleEvents,
|
|
102
|
+
timeZone: timeZoneProp,
|
|
99
103
|
weekStartsOn: weekStartsOnProp,
|
|
100
104
|
hourCycle: hourCycleProp,
|
|
101
105
|
today = sampleToday,
|
|
@@ -110,18 +114,19 @@ export function WeekCalendar({
|
|
|
110
114
|
actions,
|
|
111
115
|
className,
|
|
112
116
|
}: WeekCalendarProps) {
|
|
113
|
-
const { t, locale } = useI18n();
|
|
117
|
+
const { t, locale, timeZone: providerZone } = useI18n();
|
|
118
|
+
const timeZone = timeZoneProp ?? providerZone;
|
|
114
119
|
const clock = useSchedulingClock(hourCycleProp);
|
|
115
120
|
const weekStartsOn = weekStartsOnProp ?? localeWeekStart(clock.locale);
|
|
116
121
|
const titleId = useId();
|
|
117
|
-
const [weekStart, setWeekStart] = useState<Date>(() => startOfWeek(defaultWeek ?? today, weekStartsOn));
|
|
122
|
+
const [weekStart, setWeekStart] = useState<Date>(() => startOfWeek(defaultWeek ?? today, weekStartsOn, timeZone));
|
|
118
123
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
119
|
-
const byDay = useMemo(() => groupByDay(events), [events]);
|
|
120
|
-
const days = weekDays(weekStart, weekStartsOn);
|
|
124
|
+
const byDay = useMemo(() => groupByDay(events, timeZone), [events, timeZone]);
|
|
125
|
+
const days = weekDays(weekStart, weekStartsOn, timeZone);
|
|
121
126
|
const visibleStart = days[0] ?? weekStart;
|
|
122
127
|
const weekend = weekendDays(clock.locale);
|
|
123
128
|
const nowAt = now ?? today;
|
|
124
|
-
const nowVisible = days.some((d) => sameDay(d, nowAt));
|
|
129
|
+
const nowVisible = days.some((d) => sameDay(d, nowAt, timeZone));
|
|
125
130
|
|
|
126
131
|
useEffect(() => {
|
|
127
132
|
if (scrollRef.current) scrollRef.current.scrollTop = Math.max(scrollToHour * hourHeight - 8, 0);
|
|
@@ -135,13 +140,15 @@ export function WeekCalendar({
|
|
|
135
140
|
return (
|
|
136
141
|
<div className={cn('overflow-hidden rounded-xl border border-border bg-card', className)}>
|
|
137
142
|
<CalendarHeader
|
|
143
|
+
timeZone={timeZone}
|
|
144
|
+
referenceDate={visibleStart}
|
|
138
145
|
titleId={titleId}
|
|
139
|
-
title={formatWeekRange(days, locale)}
|
|
146
|
+
title={formatWeekRange(days, locale, timeZone)}
|
|
140
147
|
prevLabel={t('calendar.previousWeek')}
|
|
141
148
|
nextLabel={t('calendar.nextWeek')}
|
|
142
|
-
onPrev={() => show(addDays(visibleStart, -7))}
|
|
143
|
-
onNext={() => show(addDays(visibleStart, 7))}
|
|
144
|
-
onToday={() => show(startOfWeek(today, weekStartsOn))}
|
|
149
|
+
onPrev={() => show(addDays(visibleStart, -7, timeZone))}
|
|
150
|
+
onNext={() => show(addDays(visibleStart, 7, timeZone))}
|
|
151
|
+
onToday={() => show(startOfWeek(today, weekStartsOn, timeZone))}
|
|
145
152
|
actions={actions}
|
|
146
153
|
/>
|
|
147
154
|
<div className="overflow-x-auto">
|
|
@@ -150,20 +157,22 @@ export function WeekCalendar({
|
|
|
150
157
|
<div className="w-14 shrink-0 border-e border-border/70" />
|
|
151
158
|
<div className="grid flex-1 grid-cols-7">
|
|
152
159
|
{days.map((d) => {
|
|
153
|
-
const isToday = sameDay(d, today);
|
|
160
|
+
const isToday = sameDay(d, today, timeZone);
|
|
154
161
|
return (
|
|
155
162
|
<div
|
|
156
|
-
key={dayKey(d)}
|
|
163
|
+
key={dayKey(d, timeZone)}
|
|
157
164
|
className="flex flex-col items-center justify-center border-s border-border/70 py-2 first:border-s-0"
|
|
158
165
|
>
|
|
159
|
-
<span className="text-[11px] text-muted-foreground">
|
|
166
|
+
<span className="text-[11px] text-muted-foreground">
|
|
167
|
+
{formatWeekday(d, locale, 'short', timeZone)}
|
|
168
|
+
</span>
|
|
160
169
|
<span
|
|
161
170
|
className={cn(
|
|
162
171
|
'mt-1 inline-flex size-7 items-center justify-center rounded-full text-[13px] tabular-nums',
|
|
163
172
|
isToday ? 'bg-primary font-semibold text-primary-foreground' : 'font-medium text-foreground',
|
|
164
173
|
)}
|
|
165
174
|
>
|
|
166
|
-
{d.
|
|
175
|
+
{zonedParts(d, timeZone).day}
|
|
167
176
|
</span>
|
|
168
177
|
</div>
|
|
169
178
|
);
|
|
@@ -174,8 +183,8 @@ export function WeekCalendar({
|
|
|
174
183
|
ref={scrollRef}
|
|
175
184
|
tabIndex={0}
|
|
176
185
|
role="region"
|
|
177
|
-
aria-labelledby={titleId}
|
|
178
|
-
className="overflow-y-auto focus-
|
|
186
|
+
aria-labelledby={timeZone === 'system' ? titleId : `${titleId} ${titleId}-zone`}
|
|
187
|
+
className="overflow-y-auto focus-ring-inset"
|
|
179
188
|
style={{ maxHeight: height }}
|
|
180
189
|
>
|
|
181
190
|
<div className="relative flex" style={{ height: 24 * hourHeight }}>
|
|
@@ -202,25 +211,25 @@ export function WeekCalendar({
|
|
|
202
211
|
</div>
|
|
203
212
|
<div className="relative grid h-full grid-cols-7">
|
|
204
213
|
{days.map((d) => {
|
|
205
|
-
const list = byDay.get(dayKey(d)) ?? [];
|
|
214
|
+
const list = byDay.get(dayKey(d, timeZone)) ?? [];
|
|
206
215
|
return (
|
|
207
216
|
<ul
|
|
208
|
-
key={dayKey(d)}
|
|
209
|
-
data-weekend={weekend.includes(d
|
|
210
|
-
aria-label={formatDay(d, locale)}
|
|
217
|
+
key={dayKey(d, timeZone)}
|
|
218
|
+
data-weekend={weekend.includes(weekday(d, timeZone)) ? '' : undefined}
|
|
219
|
+
aria-label={formatDay(d, locale, timeZone)}
|
|
211
220
|
className="relative border-s border-border/70 first:border-s-0"
|
|
212
221
|
>
|
|
213
|
-
{layoutDay(list, hourHeight).map(({ event, top, height: h, lane, lanes }) => {
|
|
222
|
+
{layoutDay(list, hourHeight, timeZone).map(({ event, top, height: h, lane, lanes }) => {
|
|
214
223
|
const kind = kindOf(event, kinds);
|
|
215
224
|
const tone = TONE[kind.tone];
|
|
216
|
-
const range = formatRange(event.start, event.end, clock.locale, clock.hourCycle);
|
|
225
|
+
const range = formatRange(event.start, event.end, clock.locale, clock.hourCycle, timeZone);
|
|
217
226
|
const body = (
|
|
218
227
|
<>
|
|
219
228
|
<span className="block truncate text-[11px] leading-tight font-semibold text-foreground">
|
|
220
229
|
{event.title}
|
|
221
230
|
</span>
|
|
222
231
|
<span className="block truncate font-mono text-[10px] text-foreground">
|
|
223
|
-
{formatTime(event.start, clock.locale, clock.hourCycle)}
|
|
232
|
+
{formatTime(event.start, clock.locale, clock.hourCycle, timeZone)}
|
|
224
233
|
</span>
|
|
225
234
|
</>
|
|
226
235
|
);
|
|
@@ -268,8 +277,8 @@ export function WeekCalendar({
|
|
|
268
277
|
{nowVisible && (
|
|
269
278
|
<div
|
|
270
279
|
aria-hidden
|
|
271
|
-
className="pointer-events-none absolute inset-x-0 z-
|
|
272
|
-
style={{ top: hourOf(nowAt) * hourHeight }}
|
|
280
|
+
className="pointer-events-none absolute inset-x-0 z-raised flex items-center"
|
|
281
|
+
style={{ top: hourOf(nowAt, timeZone) * hourHeight }}
|
|
273
282
|
>
|
|
274
283
|
<span className="-ms-1 size-2 shrink-0 rounded-full bg-primary" />
|
|
275
284
|
<span className="h-px flex-1 bg-primary" />
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import TimeZoneExample from './examples/TimeZone';
|
|
2
|
+
import { expectNoAxeViolations } from '../../test/a11y';
|
|
3
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import { WeekCalendar } from './WeekCalendar';
|
|
6
|
+
|
|
7
|
+
it('places events and the now line on the New York clock inherited from the provider', () => {
|
|
8
|
+
vi.stubEnv('TZ', 'Europe/Madrid');
|
|
9
|
+
try {
|
|
10
|
+
render(
|
|
11
|
+
<I18nProvider locale="en-US" timeZone="America/New_York">
|
|
12
|
+
<WeekCalendar
|
|
13
|
+
weekStartsOn={1}
|
|
14
|
+
hourHeight={60}
|
|
15
|
+
today={new Date('2026-04-15T13:00:00Z')}
|
|
16
|
+
now={new Date('2026-04-15T13:30:00Z')}
|
|
17
|
+
events={[
|
|
18
|
+
{
|
|
19
|
+
id: 'ny',
|
|
20
|
+
title: 'Morning run',
|
|
21
|
+
start: new Date('2026-04-15T13:00:00Z'),
|
|
22
|
+
end: new Date('2026-04-15T14:00:00Z'),
|
|
23
|
+
},
|
|
24
|
+
]}
|
|
25
|
+
/>
|
|
26
|
+
</I18nProvider>,
|
|
27
|
+
);
|
|
28
|
+
expect(screen.getByText('Morning run').closest('li')).toHaveStyle({ top: '541px' });
|
|
29
|
+
expect(screen.getByText('Times in America/New_York (EDT)')).toBeInTheDocument();
|
|
30
|
+
expect(screen.getByText('9:00 AM')).toBeInTheDocument();
|
|
31
|
+
expect(screen.getByText('Morning run').closest('ul')).toHaveAccessibleName('Wednesday, April 15');
|
|
32
|
+
expect(screen.getByText('now').parentElement).toHaveStyle({ top: '570px' });
|
|
33
|
+
} finally {
|
|
34
|
+
vi.unstubAllEnvs();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('has no axe violations in the display-zone example', async () => {
|
|
39
|
+
const { container } = render(<TimeZoneExample />);
|
|
40
|
+
await expectNoAxeViolations(container);
|
|
41
|
+
});
|
|
@@ -5,6 +5,6 @@ export const meta: BlockMeta = {
|
|
|
5
5
|
family: 'scheduling',
|
|
6
6
|
status: 'beta',
|
|
7
7
|
description:
|
|
8
|
-
'Locale-first seven-day time grid with positioned events (overlaps side by side), a now line, week navigation and optional clickable events. 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 seven-day time grid with positioned events (overlaps side by side), a now line, week navigation and optional clickable events. 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
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
2
|
+
import { WeekCalendar } from '../WeekCalendar';
|
|
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
|
+
<WeekCalendar today={today} events={events} />
|
|
21
|
+
<WeekCalendar today={today} events={events} timeZone="America/New_York" />
|
|
22
|
+
</I18nProvider>
|
|
23
|
+
<I18nProvider locale="es-ES" timeZone="Europe/Madrid">
|
|
24
|
+
<WeekCalendar today={today} events={events} />
|
|
25
|
+
</I18nProvider>
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import { Button, IconButton, useI18n } from '@gntik-ai/ui';
|
|
2
|
+
import { Button, IconButton, useI18n, formatTimeZoneLabel } from '@gntik-ai/ui';
|
|
3
3
|
import { ChevronLeft, ChevronRight } from '@gntik-ai/icons';
|
|
4
4
|
|
|
5
5
|
export interface CalendarHeaderProps {
|
|
6
6
|
titleId: string;
|
|
7
|
+
timeZone?: string;
|
|
8
|
+
referenceDate?: Date;
|
|
7
9
|
title: string;
|
|
8
10
|
subtitle?: string;
|
|
9
11
|
prevLabel: string;
|
|
@@ -16,6 +18,8 @@ export interface CalendarHeaderProps {
|
|
|
16
18
|
|
|
17
19
|
/** Title + previous / today / next navigation + caller actions. */
|
|
18
20
|
export function CalendarHeader({
|
|
21
|
+
timeZone = 'system',
|
|
22
|
+
referenceDate,
|
|
19
23
|
titleId,
|
|
20
24
|
title,
|
|
21
25
|
subtitle,
|
|
@@ -37,6 +41,7 @@ export function CalendarHeader({
|
|
|
37
41
|
>
|
|
38
42
|
{title}
|
|
39
43
|
</h3>
|
|
44
|
+
<TimeZoneLabel id={`${titleId}-zone`} timeZone={timeZone} referenceDate={referenceDate} />
|
|
40
45
|
{subtitle && <p className="mt-0.5 truncate font-mono text-[11px] text-muted-foreground">{subtitle}</p>}
|
|
41
46
|
</div>
|
|
42
47
|
<div className="flex shrink-0 items-center gap-2">
|
|
@@ -52,3 +57,23 @@ export function CalendarHeader({
|
|
|
52
57
|
</div>
|
|
53
58
|
);
|
|
54
59
|
}
|
|
60
|
+
|
|
61
|
+
/** Shared, wrapping zone caption for calendar and agenda headers. */
|
|
62
|
+
export function TimeZoneLabel({
|
|
63
|
+
id,
|
|
64
|
+
timeZone,
|
|
65
|
+
referenceDate,
|
|
66
|
+
}: {
|
|
67
|
+
id?: string;
|
|
68
|
+
timeZone: string;
|
|
69
|
+
referenceDate?: Date;
|
|
70
|
+
}) {
|
|
71
|
+
const { t } = useI18n();
|
|
72
|
+
if (timeZone === 'system') return null;
|
|
73
|
+
const zone = timeZone === 'UTC' ? 'UTC' : `${timeZone} (${formatTimeZoneLabel(timeZone, referenceDate, 'en-US')})`;
|
|
74
|
+
return (
|
|
75
|
+
<p id={id} className="mt-0.5 break-words text-[11px] text-muted-foreground">
|
|
76
|
+
{t('scheduling.timeZone', { zone })}
|
|
77
|
+
</p>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -1,62 +1,77 @@
|
|
|
1
|
-
/** Native-Date helpers for
|
|
2
|
-
import type
|
|
1
|
+
/** Native-Date helpers for scheduling. All optional zones default to the runtime clock. */
|
|
2
|
+
import { fromZonedParts, zonedParts, type WeekDay } from '@gntik-ai/ui';
|
|
3
3
|
|
|
4
4
|
const pad = (n: number) => String(n).padStart(2, '0');
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/** Midnight in the display zone, normalizing calendar arithmetic before DST conversion. */
|
|
7
|
+
function calendarDate(year: number, month: number, day: number, zone = 'system'): Date {
|
|
8
|
+
if (zone === 'system') return new Date(year, month - 1, day);
|
|
9
|
+
const normalized = new Date(0);
|
|
10
|
+
normalized.setUTCFullYear(year, month - 1, day);
|
|
11
|
+
const parts = zonedParts(normalized, 'UTC');
|
|
12
|
+
return fromZonedParts(parts, zone)!;
|
|
9
13
|
}
|
|
10
14
|
|
|
11
|
-
export function
|
|
12
|
-
|
|
15
|
+
export function dayKey(d: Date, zone = 'system'): string {
|
|
16
|
+
const p = zonedParts(d, zone);
|
|
17
|
+
return `${p.year}-${pad(p.month)}-${pad(p.day)}`;
|
|
13
18
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
19
|
+
export function startOfDay(d: Date, zone = 'system'): Date {
|
|
20
|
+
const p = zonedParts(d, zone);
|
|
21
|
+
return calendarDate(p.year, p.month, p.day, zone);
|
|
17
22
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
23
|
+
export function addDays(d: Date, n: number, zone = 'system'): Date {
|
|
24
|
+
const p = zonedParts(d, zone);
|
|
25
|
+
return calendarDate(p.year, p.month, p.day + n, zone);
|
|
21
26
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return
|
|
27
|
+
export function addMonths(d: Date, n: number, zone = 'system'): Date {
|
|
28
|
+
const p = zonedParts(d, zone);
|
|
29
|
+
return calendarDate(p.year, p.month + n, 1, zone);
|
|
25
30
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
31
|
+
export function startOfMonth(d: Date, zone = 'system'): Date {
|
|
32
|
+
return addMonths(d, 0, zone);
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
|
|
34
|
+
export function sameDay(a: Date, b: Date, zone = 'system'): boolean {
|
|
35
|
+
return dayKey(a, zone) === dayKey(b, zone);
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return
|
|
37
|
+
export function sameMonth(a: Date, b: Date, zone = 'system'): boolean {
|
|
38
|
+
const p = zonedParts(a, zone),
|
|
39
|
+
q = zonedParts(b, zone);
|
|
40
|
+
return p.year === q.year && p.month === q.month;
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return Array.from({ length: 7 }, (_, i) => addDays(first, i));
|
|
42
|
+
export function weekday(d: Date, zone = 'system'): WeekDay {
|
|
43
|
+
const p = zonedParts(d, zone);
|
|
44
|
+
return new Date(Date.UTC(p.year, p.month - 1, p.day)).getUTCDay() as WeekDay;
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export function monthGrid(d: Date, weekStartsOn: WeekDay): Date[][] {
|
|
47
|
-
const start = startOfWeek(startOfMonth(d), weekStartsOn);
|
|
48
|
-
return Array.from({ length: 6 }, (_, w) => Array.from({ length: 7 }, (_, i) => addDays(start, w * 7 + i)));
|
|
46
|
+
export function startOfWeek(d: Date, weekStartsOn: WeekDay, zone = 'system'): Date {
|
|
47
|
+
return addDays(d, -((weekday(d, zone) - weekStartsOn + 7) % 7), zone);
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
export function weekDays(d: Date, weekStartsOn: WeekDay, zone = 'system'): Date[] {
|
|
50
|
+
const first = startOfWeek(d, weekStartsOn, zone);
|
|
51
|
+
return Array.from({ length: 7 }, (_, i) => addDays(first, i, zone));
|
|
52
|
+
}
|
|
53
|
+
export function monthGrid(d: Date, weekStartsOn: WeekDay, zone = 'system'): Date[][] {
|
|
54
|
+
const start = startOfWeek(startOfMonth(d, zone), weekStartsOn, zone);
|
|
55
|
+
return Array.from({ length: 6 }, (_, w) => Array.from({ length: 7 }, (_, i) => addDays(start, w * 7 + i, zone)));
|
|
56
|
+
}
|
|
57
|
+
export function hourOf(d: Date, zone = 'system'): number {
|
|
58
|
+
const p = zonedParts(d, zone);
|
|
59
|
+
return p.hour + p.minute / 60;
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
const cache = new Map<string, Intl.DateTimeFormat>();
|
|
63
|
+
const runtimeLocales = new WeakMap<typeof Intl.DateTimeFormat, string>();
|
|
64
|
+
function runtimeLocale(): string {
|
|
65
|
+
let locale = runtimeLocales.get(Intl.DateTimeFormat);
|
|
66
|
+
if (!locale) {
|
|
67
|
+
locale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
68
|
+
runtimeLocales.set(Intl.DateTimeFormat, locale);
|
|
69
|
+
}
|
|
70
|
+
return locale;
|
|
71
|
+
}
|
|
57
72
|
/** Cached Intl formatter; an omitted locale uses the runtime locale. */
|
|
58
73
|
const fmt = (locale: string | undefined, opts: Intl.DateTimeFormatOptions) => {
|
|
59
|
-
const key = `${locale ??
|
|
74
|
+
const key = `${locale ?? runtimeLocale()}|${JSON.stringify(opts)}`;
|
|
60
75
|
let f = cache.get(key);
|
|
61
76
|
if (!f) {
|
|
62
77
|
f = new Intl.DateTimeFormat(locale, opts);
|
|
@@ -69,11 +84,21 @@ const fmt = (locale: string | undefined, opts: Intl.DateTimeFormatOptions) => {
|
|
|
69
84
|
export type HourCycle = 'h12' | 'h23';
|
|
70
85
|
|
|
71
86
|
/** "9:30 AM" or "09:30". */
|
|
72
|
-
export const formatTime = (d: Date, locale: string | undefined, hourCycle: HourCycle) =>
|
|
73
|
-
fmt(locale, {
|
|
87
|
+
export const formatTime = (d: Date, locale: string | undefined, hourCycle: HourCycle, zone = 'system') =>
|
|
88
|
+
fmt(locale, {
|
|
89
|
+
timeZone: zone === 'system' ? undefined : zone,
|
|
90
|
+
hour: hourCycle === 'h12' ? 'numeric' : '2-digit',
|
|
91
|
+
minute: '2-digit',
|
|
92
|
+
hourCycle,
|
|
93
|
+
}).format(d);
|
|
74
94
|
/** "9:30 AM–10:00 AM" or "09:30–10:00". */
|
|
75
|
-
export const formatRange = (
|
|
76
|
-
|
|
95
|
+
export const formatRange = (
|
|
96
|
+
start: Date,
|
|
97
|
+
end: Date,
|
|
98
|
+
locale: string | undefined,
|
|
99
|
+
hourCycle: HourCycle,
|
|
100
|
+
zone = 'system',
|
|
101
|
+
) => `${formatTime(start, locale, hourCycle, zone)}–${formatTime(end, locale, hourCycle, zone)}`;
|
|
77
102
|
/** Compact gutter label: "9 AM" or "09:00". */
|
|
78
103
|
export const formatHour = (hour: number, locale: string | undefined, hourCycle: HourCycle) =>
|
|
79
104
|
fmt(locale, {
|
|
@@ -82,30 +107,49 @@ export const formatHour = (hour: number, locale: string | undefined, hourCycle:
|
|
|
82
107
|
hourCycle,
|
|
83
108
|
}).format(new Date(2026, 0, 1, hour));
|
|
84
109
|
/** "Wednesday, April 15, 2026". */
|
|
85
|
-
export const formatFullDate = (d: Date, locale?: string) =>
|
|
86
|
-
fmt(locale, {
|
|
110
|
+
export const formatFullDate = (d: Date, locale?: string, zone = 'system') =>
|
|
111
|
+
fmt(locale, {
|
|
112
|
+
timeZone: zone === 'system' ? undefined : zone,
|
|
113
|
+
weekday: 'long',
|
|
114
|
+
month: 'long',
|
|
115
|
+
day: 'numeric',
|
|
116
|
+
year: 'numeric',
|
|
117
|
+
}).format(d);
|
|
87
118
|
/** "Wednesday, April 15". */
|
|
88
|
-
export const formatDay = (d: Date, locale?: string) =>
|
|
89
|
-
fmt(locale, {
|
|
119
|
+
export const formatDay = (d: Date, locale?: string, zone = 'system') =>
|
|
120
|
+
fmt(locale, {
|
|
121
|
+
timeZone: zone === 'system' ? undefined : zone,
|
|
122
|
+
weekday: 'long',
|
|
123
|
+
month: 'long',
|
|
124
|
+
day: 'numeric',
|
|
125
|
+
}).format(d);
|
|
90
126
|
/** "April 2026". */
|
|
91
|
-
export const formatMonth = (d: Date, locale?: string
|
|
127
|
+
export const formatMonth = (d: Date, locale?: string, zone = 'system') =>
|
|
128
|
+
fmt(locale, { timeZone: zone === 'system' ? undefined : zone, month: 'long', year: 'numeric' }).format(d);
|
|
92
129
|
/** "Apr 15". */
|
|
93
|
-
export const formatShort = (d: Date, locale?: string
|
|
130
|
+
export const formatShort = (d: Date, locale?: string, zone = 'system') =>
|
|
131
|
+
fmt(locale, { timeZone: zone === 'system' ? undefined : zone, month: 'short', day: 'numeric' }).format(d);
|
|
94
132
|
/** "Wed". */
|
|
95
|
-
export const formatWeekday = (d: Date, locale?: string, weekday: 'short' | 'long' = 'short') =>
|
|
96
|
-
fmt(locale, { weekday }).format(d);
|
|
133
|
+
export const formatWeekday = (d: Date, locale?: string, weekday: 'short' | 'long' = 'short', zone = 'system') =>
|
|
134
|
+
fmt(locale, { timeZone: zone === 'system' ? undefined : zone, weekday }).format(d);
|
|
97
135
|
|
|
98
136
|
/** "Apr 13 – 19, 2026" (or across months / years). */
|
|
99
|
-
export function formatWeekRange(days: readonly Date[], locale?: string): string {
|
|
137
|
+
export function formatWeekRange(days: readonly Date[], locale?: string, zone = 'system'): string {
|
|
100
138
|
const first = days[0];
|
|
101
139
|
const last = days[days.length - 1];
|
|
102
140
|
if (!first || !last) return '';
|
|
103
141
|
if (locale && !locale.toLowerCase().startsWith('en'))
|
|
104
|
-
return fmt(locale, {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
142
|
+
return fmt(locale, {
|
|
143
|
+
timeZone: zone === 'system' ? undefined : zone,
|
|
144
|
+
month: 'short',
|
|
145
|
+
day: 'numeric',
|
|
146
|
+
year: 'numeric',
|
|
147
|
+
}).formatRange(first, last);
|
|
148
|
+
if (sameMonth(first, last, zone))
|
|
149
|
+
return `${formatShort(first, 'en-US', zone)} – ${zonedParts(last, zone).day}, ${zonedParts(last, zone).year}`;
|
|
150
|
+
if (zonedParts(first, zone).year === zonedParts(last, zone).year)
|
|
151
|
+
return `${formatShort(first, 'en-US', zone)} – ${formatShort(last, 'en-US', zone)}, ${zonedParts(last, zone).year}`;
|
|
152
|
+
return `${formatShort(first, 'en-US', zone)}, ${zonedParts(first, zone).year} – ${formatShort(last, 'en-US', zone)}, ${zonedParts(last, zone).year}`;
|
|
109
153
|
}
|
|
110
154
|
|
|
111
155
|
/** Internal to blocks: Intl weekdays 1–7 become JS weekdays 0–6. */
|
|
@@ -77,10 +77,10 @@ export const TONE: Record<EventTone, { dot: string; soft: string; bar: string; i
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
/** Events grouped by local day key, each day sorted by start. */
|
|
80
|
-
export function groupByDay(events: readonly ScheduleEvent[]): Map<string, ScheduleEvent[]> {
|
|
80
|
+
export function groupByDay(events: readonly ScheduleEvent[], timeZone = 'system'): Map<string, ScheduleEvent[]> {
|
|
81
81
|
const map = new Map<string, ScheduleEvent[]>();
|
|
82
82
|
for (const e of events) {
|
|
83
|
-
const key = dayKey(e.start);
|
|
83
|
+
const key = dayKey(e.start, timeZone);
|
|
84
84
|
const list = map.get(key);
|
|
85
85
|
if (list) list.push(e);
|
|
86
86
|
else map.set(key, [e]);
|