@flamingo-stack/openframe-frontend-core 0.0.642 → 0.0.643-snapshot.20260916153353
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/chat-protocol/index.cjs +6 -3
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +6 -3
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/source-metadata.d.ts +16 -1
- package/dist/chat-protocol/source-metadata.d.ts.map +1 -1
- package/dist/{chunk-YM6L3WM5.js → chunk-27RD5XTP.js} +3 -3
- package/dist/{chunk-POPL3W2S.js → chunk-3DGRXC74.js} +3 -3
- package/dist/{chunk-2Z5FPHOL.cjs → chunk-3UBT2OIX.cjs} +20 -20
- package/dist/{chunk-2Z5FPHOL.cjs.map → chunk-3UBT2OIX.cjs.map} +1 -1
- package/dist/{chunk-6GY6DFIH.js → chunk-4WVWRFGP.js} +6 -6
- package/dist/{chunk-OYI3K5R6.cjs → chunk-65EVGKFV.cjs} +8 -14
- package/dist/chunk-65EVGKFV.cjs.map +1 -0
- package/dist/{chunk-6NHLZORM.js → chunk-7Q5XXPCB.js} +6 -6
- package/dist/{chunk-2NRLRRMR.cjs → chunk-7R2DIGG4.cjs} +319 -293
- package/dist/chunk-7R2DIGG4.cjs.map +1 -0
- package/dist/{chunk-3LXJEXPH.js → chunk-B3Z3RJRW.js} +2 -2
- package/dist/{chunk-N5C5P2LM.cjs → chunk-B5IFXCRF.cjs} +22 -22
- package/dist/{chunk-N5C5P2LM.cjs.map → chunk-B5IFXCRF.cjs.map} +1 -1
- package/dist/{chunk-YRSRP4U3.cjs → chunk-C5Y5T6GC.cjs} +15 -15
- package/dist/{chunk-YRSRP4U3.cjs.map → chunk-C5Y5T6GC.cjs.map} +1 -1
- package/dist/{chunk-VHB3I6F3.cjs → chunk-CBXZSTAG.cjs} +419 -445
- package/dist/chunk-CBXZSTAG.cjs.map +1 -0
- package/dist/{chunk-VKPTN5MT.cjs → chunk-DCCY54LU.cjs} +6 -6
- package/dist/{chunk-VKPTN5MT.cjs.map → chunk-DCCY54LU.cjs.map} +1 -1
- package/dist/{chunk-WL3PNUNY.cjs → chunk-FAD5WURS.cjs} +81 -81
- package/dist/{chunk-WL3PNUNY.cjs.map → chunk-FAD5WURS.cjs.map} +1 -1
- package/dist/{chunk-3IPL6G7S.js → chunk-FOSIR4QF.js} +260 -234
- package/dist/chunk-FOSIR4QF.js.map +1 -0
- package/dist/{chunk-MJ424FEC.js → chunk-HOGOQA2X.js} +2 -2
- package/dist/{chunk-SDGMLXIP.js → chunk-HPWLIYRL.js} +12 -25
- package/dist/chunk-HPWLIYRL.js.map +1 -0
- package/dist/{chunk-3I6XHQUD.js → chunk-I57XLISO.js} +54 -80
- package/dist/chunk-I57XLISO.js.map +1 -0
- package/dist/{chunk-FRCUUK5X.cjs → chunk-IIXB5REN.cjs} +3 -3
- package/dist/{chunk-FRCUUK5X.cjs.map → chunk-IIXB5REN.cjs.map} +1 -1
- package/dist/{chunk-HW7BLVQH.js → chunk-IXD6SHQ6.js} +4 -4
- package/dist/{chunk-XFLJC2WR.cjs → chunk-LZYPSDFE.cjs} +59 -59
- package/dist/{chunk-XFLJC2WR.cjs.map → chunk-LZYPSDFE.cjs.map} +1 -1
- package/dist/{chunk-QY25ZP2V.cjs → chunk-MCQAOIUK.cjs} +28 -28
- package/dist/{chunk-QY25ZP2V.cjs.map → chunk-MCQAOIUK.cjs.map} +1 -1
- package/dist/{chunk-S254VEDE.js → chunk-MRIOYSXH.js} +3 -3
- package/dist/{chunk-OOOOC5O5.cjs → chunk-OMSUWB6A.cjs} +29 -29
- package/dist/{chunk-OOOOC5O5.cjs.map → chunk-OMSUWB6A.cjs.map} +1 -1
- package/dist/{chunk-GEIHTN6J.cjs → chunk-OVXYX47B.cjs} +10 -10
- package/dist/{chunk-GEIHTN6J.cjs.map → chunk-OVXYX47B.cjs.map} +1 -1
- package/dist/{chunk-XWGHLSAL.js → chunk-PFV4DAX5.js} +4 -4
- package/dist/{chunk-O4LL7RQV.cjs → chunk-RB6L5EGM.cjs} +208 -221
- package/dist/chunk-RB6L5EGM.cjs.map +1 -0
- package/dist/{chunk-M4PJVFBF.cjs → chunk-RFFF2EYD.cjs} +11 -11
- package/dist/{chunk-M4PJVFBF.cjs.map → chunk-RFFF2EYD.cjs.map} +1 -1
- package/dist/{chunk-UFBWNVZZ.js → chunk-RNMGKAS6.js} +7 -7
- package/dist/{chunk-SE6YRE3R.cjs → chunk-RWURXICE.cjs} +32 -32
- package/dist/{chunk-SE6YRE3R.cjs.map → chunk-RWURXICE.cjs.map} +1 -1
- package/dist/{chunk-ZAIYD3MZ.js → chunk-S2KMNFFN.js} +3 -3
- package/dist/{chunk-ZGPJ3NVF.js → chunk-SKABQX44.js} +3 -3
- package/dist/{chunk-YE3TFNW6.cjs → chunk-TGUA3C4U.cjs} +5 -5
- package/dist/{chunk-YE3TFNW6.cjs.map → chunk-TGUA3C4U.cjs.map} +1 -1
- package/dist/{chunk-ORFJVMAL.js → chunk-TTVOBWAH.js} +5 -11
- package/dist/chunk-TTVOBWAH.js.map +1 -0
- package/dist/{chunk-M7QROULE.js → chunk-UEXIMEVU.js} +5 -5
- package/dist/{chunk-EW3MSJOE.cjs → chunk-UKV52KAP.cjs} +33 -33
- package/dist/{chunk-EW3MSJOE.cjs.map → chunk-UKV52KAP.cjs.map} +1 -1
- package/dist/{chunk-J4RZVLLQ.js → chunk-VE52MSYC.js} +5 -5
- package/dist/components/case-studies/index.cjs +16 -16
- package/dist/components/case-studies/index.js +4 -4
- package/dist/components/chat/chat-sidebar.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/blog-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +3 -9
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +2 -8
- package/dist/components/chat/types/entities/investor-update.d.ts.map +1 -1
- package/dist/components/chat/types/entities/program-types.d.ts +8 -18
- package/dist/components/chat/types/entities/program-types.d.ts.map +1 -1
- package/dist/components/chat/utils/compact-card-classes.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +5 -5
- package/dist/components/contact/index.js +4 -4
- package/dist/components/docs/index.cjs +8 -8
- package/dist/components/docs/index.js +7 -7
- package/dist/components/embeds/index.cjs +5 -5
- package/dist/components/embeds/index.js +4 -4
- package/dist/components/faq/index.cjs +5 -5
- package/dist/components/faq/index.js +4 -4
- package/dist/components/features/index.cjs +4 -4
- package/dist/components/features/index.js +3 -3
- package/dist/components/help-center-pages/index.cjs +24 -24
- package/dist/components/help-center-pages/index.js +15 -15
- package/dist/components/index.cjs +53 -59
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +15 -21
- package/dist/components/index.js.map +1 -1
- package/dist/components/logs-list.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/confirmation.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/directory.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +47 -72
- package/dist/components/meeting-scheduler/index.cjs.map +1 -1
- package/dist/components/meeting-scheduler/index.d.ts.map +1 -1
- package/dist/components/meeting-scheduler/index.js +16 -41
- package/dist/components/meeting-scheduler/index.js.map +1 -1
- package/dist/components/meeting-scheduler/slot-picker.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +7 -7
- package/dist/components/navigation/index.js +6 -6
- package/dist/components/onboarding-guides/index.cjs +7 -7
- package/dist/components/onboarding-guides/index.js +6 -6
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/shared/article-author-byline.d.ts.map +1 -1
- package/dist/components/tickets/index.cjs +8 -8
- package/dist/components/tickets/index.js +7 -7
- package/dist/components/ui/date-picker.d.ts.map +1 -1
- package/dist/components/ui/device-card.d.ts.map +1 -1
- package/dist/components/ui/drawer.d.ts +19 -5
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +4 -10
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +3 -9
- package/dist/components/ui/table/table-timestamp-cell.d.ts.map +1 -1
- package/dist/index.cjs +29 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -23
- package/dist/index.js.map +1 -1
- package/dist/utils/date-formatters.d.ts +7 -2
- package/dist/utils/date-formatters.d.ts.map +1 -1
- package/dist/utils/date-utils.d.ts +4 -1
- package/dist/utils/date-utils.d.ts.map +1 -1
- package/dist/utils/format-date.d.ts.map +1 -1
- package/dist/utils/format.d.ts +155 -11
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/index.cjs +223 -109
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +211 -110
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/program-instant.d.ts +145 -0
- package/dist/utils/program-instant.d.ts.map +1 -0
- package/dist/utils/program-meta-renderers.d.ts +3 -0
- package/dist/utils/program-meta-renderers.d.ts.map +1 -0
- package/dist/utils/url-safety.d.ts +33 -0
- package/dist/utils/url-safety.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/chat-protocol/__tests__/source-metadata.test.ts +70 -3
- package/src/chat-protocol/source-metadata.ts +22 -6
- package/src/components/chat/chat-sidebar.tsx +4 -11
- package/src/components/chat/entity-cards/.program-card.md +1 -1
- package/src/components/chat/entity-cards/blog-card.tsx +4 -24
- package/src/components/chat/entity-cards/dispatch.tsx +9 -27
- package/src/components/chat/entity-cards/program-card.tsx +42 -81
- package/src/components/chat/types/entities/investor-update.ts +4 -6
- package/src/components/chat/types/entities/program-types.ts +8 -89
- package/src/components/chat/utils/.compact-card-classes.md +1 -1
- package/src/components/chat/utils/compact-card-classes.ts +5 -3
- package/src/components/logs-list.tsx +4 -13
- package/src/components/meeting-scheduler/confirmation.tsx +6 -10
- package/src/components/meeting-scheduler/directory.tsx +2 -12
- package/src/components/meeting-scheduler/index.tsx +3 -11
- package/src/components/meeting-scheduler/slot-picker.tsx +4 -7
- package/src/components/shared/article-author-byline.tsx +4 -13
- package/src/components/ui/.drawer.md +1 -0
- package/src/components/ui/__tests__/drawer-size.test.tsx +38 -0
- package/src/components/ui/date-picker.tsx +6 -13
- package/src/components/ui/device-card.tsx +4 -10
- package/src/components/ui/drawer.tsx +44 -9
- package/src/components/ui/table/table-timestamp-cell.tsx +8 -2
- package/src/utils/.format.md +5 -2
- package/src/utils/__tests__/date-rendering.test.ts +118 -0
- package/src/utils/__tests__/format-program-dates.test.ts +148 -0
- package/src/utils/__tests__/program-instant.test.ts +125 -0
- package/src/utils/__tests__/url-safety.test.ts +44 -0
- package/src/utils/date-formatters.ts +18 -29
- package/src/utils/date-utils.ts +27 -40
- package/src/utils/format-date.ts +14 -16
- package/src/utils/format.ts +367 -66
- package/src/utils/index.ts +24 -0
- package/src/utils/program-instant.ts +180 -0
- package/src/utils/program-meta-renderers.ts +18 -0
- package/src/utils/url-safety.ts +43 -0
- package/dist/chunk-2NRLRRMR.cjs.map +0 -1
- package/dist/chunk-3I6XHQUD.js.map +0 -1
- package/dist/chunk-3IPL6G7S.js.map +0 -1
- package/dist/chunk-O4LL7RQV.cjs.map +0 -1
- package/dist/chunk-ORFJVMAL.js.map +0 -1
- package/dist/chunk-OYI3K5R6.cjs.map +0 -1
- package/dist/chunk-SDGMLXIP.js.map +0 -1
- package/dist/chunk-VHB3I6F3.cjs.map +0 -1
- /package/dist/{chunk-YM6L3WM5.js.map → chunk-27RD5XTP.js.map} +0 -0
- /package/dist/{chunk-POPL3W2S.js.map → chunk-3DGRXC74.js.map} +0 -0
- /package/dist/{chunk-6GY6DFIH.js.map → chunk-4WVWRFGP.js.map} +0 -0
- /package/dist/{chunk-6NHLZORM.js.map → chunk-7Q5XXPCB.js.map} +0 -0
- /package/dist/{chunk-3LXJEXPH.js.map → chunk-B3Z3RJRW.js.map} +0 -0
- /package/dist/{chunk-MJ424FEC.js.map → chunk-HOGOQA2X.js.map} +0 -0
- /package/dist/{chunk-HW7BLVQH.js.map → chunk-IXD6SHQ6.js.map} +0 -0
- /package/dist/{chunk-S254VEDE.js.map → chunk-MRIOYSXH.js.map} +0 -0
- /package/dist/{chunk-XWGHLSAL.js.map → chunk-PFV4DAX5.js.map} +0 -0
- /package/dist/{chunk-UFBWNVZZ.js.map → chunk-RNMGKAS6.js.map} +0 -0
- /package/dist/{chunk-ZAIYD3MZ.js.map → chunk-S2KMNFFN.js.map} +0 -0
- /package/dist/{chunk-ZGPJ3NVF.js.map → chunk-SKABQX44.js.map} +0 -0
- /package/dist/{chunk-M7QROULE.js.map → chunk-UEXIMEVU.js.map} +0 -0
- /package/dist/{chunk-J4RZVLLQ.js.map → chunk-VE52MSYC.js.map} +0 -0
|
@@ -19,14 +19,15 @@
|
|
|
19
19
|
* and pass the resolved detail URL via `href`.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { format } from 'date-fns';
|
|
23
22
|
import { ExternalLink, Clock, Play, Video } from 'lucide-react';
|
|
24
23
|
import type React from 'react';
|
|
25
24
|
import { useState } from 'react';
|
|
26
25
|
import Image from '../../../embed-shims/next-image';
|
|
27
26
|
import { cn } from '../../../utils/cn';
|
|
28
|
-
import {
|
|
27
|
+
import { formatProgramDate } from '../../../utils/format';
|
|
29
28
|
import { isImageMedia } from '../../../utils/media-type';
|
|
29
|
+
import { programMetaFormatters, programMetaLine } from '../../../utils/program-instant';
|
|
30
|
+
import { PROGRAM_META_RENDERERS } from '../../../utils/program-meta-renderers';
|
|
30
31
|
import { Button } from '../../ui/button/button';
|
|
31
32
|
import { ImageGalleryModal } from '../../ui/image-gallery-modal';
|
|
32
33
|
import { SquareAvatar } from '../../ui/square-avatar';
|
|
@@ -52,26 +53,8 @@ import {
|
|
|
52
53
|
import { EntityPortraitCard } from './entity-portrait-card';
|
|
53
54
|
import { useEntityCardLink } from './use-entity-card-link';
|
|
54
55
|
import { useEntityCardPlaceholder } from './use-entity-card-placeholder';
|
|
55
|
-
type CardSize = 'default' | 'sm' | 'portrait';
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
* Format a Date with date-fns pinned to UTC. `date-fns` `format()` reads the
|
|
59
|
-
* runtime's LOCAL wall-clock, so the same instant renders differently on the
|
|
60
|
-
* server (Vercel = UTC) and the client (visitor tz) → React #418 hydration
|
|
61
|
-
* mismatch. Shifting by the local offset before formatting emits the UTC
|
|
62
|
-
* wall-clock on every machine, so server and client agree. Mirrors the helper
|
|
63
|
-
* in the hub's `program-header.tsx` (kept local — the lib has no date-fns-tz
|
|
64
|
-
* dep) and the repo-wide "pin program dates to UTC" convention.
|
|
65
|
-
*/
|
|
66
|
-
function formatUtc(date: Date, fmt: string): string {
|
|
67
|
-
// A row can legitimately arrive without a date (the field is not guaranteed by
|
|
68
|
-
// the wire type), and `new Date(undefined)` / `new Date('')` both give an
|
|
69
|
-
// Invalid Date, which makes date-fns `format()` throw RangeError. Thrown from
|
|
70
|
-
// render that takes down the whole card rail, not just this card — so the
|
|
71
|
-
// helper is total and an unknown date renders as nothing.
|
|
72
|
-
if (Number.isNaN(date.getTime())) return '';
|
|
73
|
-
return format(new Date(date.getTime() + date.getTimezoneOffset() * 60_000), fmt);
|
|
74
|
-
}
|
|
57
|
+
type CardSize = 'default' | 'sm' | 'portrait';
|
|
75
58
|
|
|
76
59
|
export function ProgramCardSkeleton({ size = 'default' }: { size?: CardSize }) {
|
|
77
60
|
if (size === 'sm') {
|
|
@@ -176,24 +159,6 @@ function getHosts(hosts: ProgramHost[] | null | undefined): Array<{ name: string
|
|
|
176
159
|
return [];
|
|
177
160
|
}
|
|
178
161
|
|
|
179
|
-
/**
|
|
180
|
-
* Webinar scheduling columns, read off a `BaseProgramItem` that has already
|
|
181
|
-
* been `in`-guarded for `start_at`. Each field is validated rather than
|
|
182
|
-
* asserted — the generic item type does not declare them.
|
|
183
|
-
*/
|
|
184
|
-
function webinarTiming(item: BaseProgramItem): {
|
|
185
|
-
startAt: string | null;
|
|
186
|
-
endAt: string | null;
|
|
187
|
-
timezone: string | null;
|
|
188
|
-
} {
|
|
189
|
-
const str = (value: unknown): string | null => (typeof value === 'string' && value ? value : null);
|
|
190
|
-
return {
|
|
191
|
-
startAt: 'start_at' in item ? str(item.start_at) : null,
|
|
192
|
-
endAt: 'end_at' in item ? str(item.end_at) : null,
|
|
193
|
-
timezone: 'timezone' in item ? str(item.timezone) : null,
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
|
|
197
162
|
function MediaGallery({ images, title }: { images: ProgramMedia[]; title: string }) {
|
|
198
163
|
const [selectedImageIndex, setSelectedImageIndex] = useState<number | null>(null);
|
|
199
164
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
@@ -282,24 +247,16 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
282
247
|
// below is followed by a real type check instead of a cast.
|
|
283
248
|
const isScheduled = 'status' in item && item.status === 'scheduled';
|
|
284
249
|
|
|
285
|
-
//
|
|
286
|
-
//
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const { startAt, endAt, timezone } = webinarTiming(item);
|
|
296
|
-
const time = formatTimeWithTimezone(startAt, timezone);
|
|
297
|
-
const dur = formatDurationFromRange(startAt, endAt);
|
|
298
|
-
return dur ? `${time} · ${dur}` : time;
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
};
|
|
302
|
-
const compactDate = formatUtc(new Date(item.date), 'MMM d, yyyy');
|
|
250
|
+
// The compact meta line, built by the ONE shared function — the chat card
|
|
251
|
+
// renders the same string from the same code rather than mirroring it.
|
|
252
|
+
const {
|
|
253
|
+
at: zonedDate,
|
|
254
|
+
typeMeta: compactTypeMetaValue,
|
|
255
|
+
line: compactMetaLine,
|
|
256
|
+
// Compact densities join plain strings, so the zone rides inline here; the
|
|
257
|
+
// default density below renders it as its own styled span instead.
|
|
258
|
+
} = programMetaLine(item, config.type, programMetaFormatters(PROGRAM_META_RENDERERS));
|
|
259
|
+
const compactDate = formatProgramDate(zonedDate, 'medium');
|
|
303
260
|
|
|
304
261
|
if (size === 'portrait') {
|
|
305
262
|
// Rail/strip density — mapped onto the shared <EntityPortraitCard> shell
|
|
@@ -308,7 +265,7 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
308
265
|
// host); the date · duration meta line fills the subtitle when the
|
|
309
266
|
// profile has no job title.
|
|
310
267
|
const profile = programItemToStripProfile(item);
|
|
311
|
-
const dateMeta =
|
|
268
|
+
const dateMeta = compactMetaLine;
|
|
312
269
|
return (
|
|
313
270
|
<EntityPortraitCard
|
|
314
271
|
href={href}
|
|
@@ -333,7 +290,7 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
333
290
|
if (size === 'sm') {
|
|
334
291
|
const itemDate = compactDate;
|
|
335
292
|
const compactCover = coverImage || placeholderUrl || null;
|
|
336
|
-
const typeMeta =
|
|
293
|
+
const typeMeta = compactTypeMetaValue;
|
|
337
294
|
const subtitleParts = [itemDate, typeMeta, config.labels?.singular].filter(
|
|
338
295
|
(s): s is string => typeof s === 'string' && s.length > 0,
|
|
339
296
|
);
|
|
@@ -377,38 +334,42 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
377
334
|
);
|
|
378
335
|
}
|
|
379
336
|
|
|
380
|
-
const
|
|
381
|
-
|
|
337
|
+
const dateFormat = formatProgramDate(zonedDate, 'weekday');
|
|
338
|
+
|
|
339
|
+
// The same dispatch as the compact densities — WHICH value a type shows is
|
|
340
|
+
// decided once, by `programMetaLine`. Only the presentation differs here
|
|
341
|
+
// (an icon, and the zone as its own styled span rather than inline), which is
|
|
342
|
+
// why this asks for an unlabelled webinar value. Restating the dispatch is
|
|
343
|
+
// how the two ended up with three conditions that disagreed: the podcast one
|
|
344
|
+
// dropped the `> 0` check, and the event one dropped the non-empty check.
|
|
345
|
+
const { typeMeta: defaultTypeMeta } = programMetaLine(
|
|
346
|
+
item,
|
|
347
|
+
config.type,
|
|
348
|
+
programMetaFormatters(PROGRAM_META_RENDERERS, { withZoneLabel: false }),
|
|
349
|
+
);
|
|
382
350
|
|
|
383
351
|
const defaultRenderMeta = () => {
|
|
384
|
-
if (config.type === 'podcast'
|
|
385
|
-
|
|
386
|
-
return (
|
|
352
|
+
if (config.type === 'podcast') {
|
|
353
|
+
return defaultTypeMeta ? (
|
|
387
354
|
<>
|
|
388
355
|
<Clock className="h-4 w-4 text-ods-text-secondary" />
|
|
389
|
-
<span className="font-body text-ods-text-secondary">
|
|
390
|
-
{formatDurationCompact(typeof dur === 'number' ? dur : null)}
|
|
391
|
-
</span>
|
|
356
|
+
<span className="font-body text-ods-text-secondary">{defaultTypeMeta}</span>
|
|
392
357
|
</>
|
|
393
|
-
);
|
|
358
|
+
) : null;
|
|
394
359
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
360
|
+
// No 'Location TBD' fallback: the page header hides the tile entirely for
|
|
361
|
+
// an event with no location, and two surfaces answering "where is this?"
|
|
362
|
+
// differently — one silent, one confidently "TBD" — is the drift this
|
|
363
|
+
// shared dispatch exists to end.
|
|
364
|
+
if (config.type === 'event') {
|
|
365
|
+
return defaultTypeMeta ? <span className="font-body text-ods-text-secondary">{defaultTypeMeta}</span> : null;
|
|
400
366
|
}
|
|
401
|
-
if (config.type === 'webinar' &&
|
|
402
|
-
const { startAt, endAt, timezone } = webinarTiming(item);
|
|
403
|
-
const duration = formatDurationFromRange(startAt, endAt);
|
|
367
|
+
if (config.type === 'webinar' && (defaultTypeMeta || zonedDate.timezone)) {
|
|
404
368
|
return (
|
|
405
369
|
<>
|
|
406
370
|
<Video className="h-4 w-4 text-ods-text-secondary" />
|
|
407
|
-
<span className="font-body text-ods-text-secondary">
|
|
408
|
-
|
|
409
|
-
{duration && ` · ${duration}`}
|
|
410
|
-
</span>
|
|
411
|
-
{timezone && <span className="text-ods-text-secondary text-h6">({timezone})</span>}
|
|
371
|
+
{defaultTypeMeta && <span className="font-body text-ods-text-secondary">{defaultTypeMeta}</span>}
|
|
372
|
+
{zonedDate.timezone && <span className="text-ods-text-secondary text-h6">({zonedDate.timezone})</span>}
|
|
412
373
|
</>
|
|
413
374
|
);
|
|
414
375
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* formatter move here.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { formatDateWithTimezone } from '../../../../utils/format';
|
|
11
12
|
import type { ContentRef } from './content-ref';
|
|
12
13
|
|
|
13
14
|
export interface MetricEntry {
|
|
@@ -89,13 +90,10 @@ export function formatInvestorUpdatePeriod(
|
|
|
89
90
|
options?: { monthFormat?: 'short' | 'long' },
|
|
90
91
|
): string {
|
|
91
92
|
if (!start && !end) return '';
|
|
93
|
+
// A reporting period is a content date: UTC-pinned through the one renderer.
|
|
94
|
+
// An unreadable date reads like a missing one ('?'), not as an empty half.
|
|
92
95
|
const fmt = (d: string) =>
|
|
93
|
-
|
|
94
|
-
month: options?.monthFormat || 'short',
|
|
95
|
-
year: 'numeric',
|
|
96
|
-
// Pin to UTC so SSR (Vercel = UTC) and the client agree (React #418).
|
|
97
|
-
timeZone: 'UTC',
|
|
98
|
-
});
|
|
96
|
+
formatDateWithTimezone(d, null, options?.monthFormat === 'long' ? 'monthYear' : 'monthYearShort') || '?';
|
|
99
97
|
const s = start ? fmt(start) : '?';
|
|
100
98
|
const e = end ? fmt(end) : '?';
|
|
101
99
|
return `${s} - ${e}`;
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
* 3. Configuration-Driven: Program types defined via configuration objects
|
|
11
11
|
* 4. Admin Consistency: Same patterns work for public pages and admin CRUD
|
|
12
12
|
*
|
|
13
|
-
* Lifted from `lib/types/program-types.ts` in the hub.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* Lifted from `lib/types/program-types.ts` in the hub.
|
|
14
|
+
*
|
|
15
|
+
* The pure row→item transform helpers that used to live here are GONE. They
|
|
16
|
+
* had no caller in this package or in the host app. The host app keeps its
|
|
17
|
+
* own transforms, which resolve the date.
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
import type { ReactNode } from 'react';
|
|
@@ -166,6 +167,9 @@ export interface BaseProgramItem {
|
|
|
166
167
|
description: string | null;
|
|
167
168
|
cover_url: string | null; // Primary image
|
|
168
169
|
date: string; // ISO date string - maps to: start_at, published_at
|
|
170
|
+
/** The event's IANA zone, when the row declares one. Read through
|
|
171
|
+
* `programDateInstant`, never directly — see that module on why. */
|
|
172
|
+
timezone?: string | null;
|
|
169
173
|
external_url?: string | null; // Registration/play link
|
|
170
174
|
hosts?: ProgramHost[] | null; // Speakers/hosts
|
|
171
175
|
// Platform tagging lives in the host app's `entity_platforms` array (exposed
|
|
@@ -377,88 +381,3 @@ export interface AdminProgramFilter extends ProgramFilter {
|
|
|
377
381
|
// ============================================================================
|
|
378
382
|
// TRANSFORM UTILITIES
|
|
379
383
|
// ============================================================================
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Transform a database event row to EventItem
|
|
383
|
-
*/
|
|
384
|
-
export function transformEventToProgram(event: LumaEventRow): EventItem {
|
|
385
|
-
return {
|
|
386
|
-
id: event.id,
|
|
387
|
-
title: event.name,
|
|
388
|
-
description: event.description ?? null,
|
|
389
|
-
cover_url: event.cover_url ?? null,
|
|
390
|
-
date: event.start_at,
|
|
391
|
-
external_url: event.event_url ?? null,
|
|
392
|
-
hosts: event.hosts ?? null,
|
|
393
|
-
luma_api_id: event.luma_api_id,
|
|
394
|
-
end_at: event.end_at,
|
|
395
|
-
timezone: event.timezone ?? null,
|
|
396
|
-
location_name: event.location_name ?? null,
|
|
397
|
-
location_full_address: event.location_full_address ?? null,
|
|
398
|
-
geo_latitude: event.geo_latitude ?? null,
|
|
399
|
-
geo_longitude: event.geo_longitude ?? null,
|
|
400
|
-
meeting_url: event.meeting_url ?? null,
|
|
401
|
-
event_url: event.event_url ?? null,
|
|
402
|
-
guest_count: event.guest_count ?? null,
|
|
403
|
-
visibility: event.visibility ?? null,
|
|
404
|
-
is_deleted: event.is_deleted ?? false,
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Transform a database podcast row to PodcastItem
|
|
410
|
-
*/
|
|
411
|
-
export function transformPodcastToProgram(episode: PodcastEpisodeRow): PodcastItem {
|
|
412
|
-
return {
|
|
413
|
-
id: episode.id,
|
|
414
|
-
title: episode.title,
|
|
415
|
-
description: episode.description ?? null,
|
|
416
|
-
// Use cover_image_override if set, otherwise use cover_url
|
|
417
|
-
cover_url: episode.cover_image_override ?? episode.cover_url ?? null,
|
|
418
|
-
date: episode.published_at ?? episode.created_at,
|
|
419
|
-
external_url: episode.external_url ?? null,
|
|
420
|
-
hosts: episode.hosts ?? null,
|
|
421
|
-
podbean_episode_id: episode.podbean_episode_id,
|
|
422
|
-
podbean_podcast_id: episode.podbean_podcast_id,
|
|
423
|
-
audio_url: episode.audio_url ?? null,
|
|
424
|
-
main_video_url: episode.main_video_url ?? null,
|
|
425
|
-
media_type: episode.media_type ?? 'audio',
|
|
426
|
-
duration_seconds: episode.duration_seconds ?? null,
|
|
427
|
-
status: episode.status ?? 'published',
|
|
428
|
-
published_at: episode.published_at ?? null,
|
|
429
|
-
is_deleted: episode.is_deleted ?? false,
|
|
430
|
-
// Override fields
|
|
431
|
-
cover_image_override: episode.cover_image_override ?? null,
|
|
432
|
-
custom_video_url: episode.custom_video_url ?? null,
|
|
433
|
-
};
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Transform a database webinar row to WebinarItem
|
|
438
|
-
* Uses display_date_override for date field when available (for backdating)
|
|
439
|
-
* Uses cover_image_override for cover_url when available
|
|
440
|
-
*/
|
|
441
|
-
export function transformWebinarToProgram(webinar: WebinarRow): WebinarItem {
|
|
442
|
-
return {
|
|
443
|
-
id: webinar.id,
|
|
444
|
-
title: webinar.title,
|
|
445
|
-
description: webinar.description ?? null,
|
|
446
|
-
// Use cover_image_override if set, otherwise use cover_url
|
|
447
|
-
cover_url: webinar.cover_image_override ?? webinar.cover_url ?? null,
|
|
448
|
-
// Use display_date_override if set, otherwise use start_at
|
|
449
|
-
date: webinar.display_date_override ?? webinar.start_at,
|
|
450
|
-
external_url: webinar.registration_url ?? null,
|
|
451
|
-
hosts: webinar.hosts ?? null,
|
|
452
|
-
livestorm_event_id: webinar.livestorm_event_id,
|
|
453
|
-
start_at: webinar.start_at,
|
|
454
|
-
end_at: webinar.end_at ?? null,
|
|
455
|
-
timezone: webinar.timezone ?? null,
|
|
456
|
-
registration_url: webinar.registration_url ?? null,
|
|
457
|
-
is_deleted: webinar.is_deleted ?? false,
|
|
458
|
-
main_video_url: webinar.main_video_url ?? null,
|
|
459
|
-
// Override fields
|
|
460
|
-
custom_video_url: webinar.custom_video_url ?? null,
|
|
461
|
-
display_date_override: webinar.display_date_override ?? null,
|
|
462
|
-
cover_image_override: webinar.cover_image_override ?? null,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
@@ -28,7 +28,7 @@ Single source of truth for compact card Tailwind class constants and URL safety
|
|
|
28
28
|
|
|
29
29
|
Allowed:
|
|
30
30
|
- `http:`, `https:`, `mailto:` schemes
|
|
31
|
-
- Same-origin paths
|
|
31
|
+
- Same-origin paths — decided by RESOLVING the candidate and comparing origins (`isSameOriginPath`), not by a `/` vs `//` prefix test: the URL parser treats a backslash as a slash in the authority position, so a single-slash path can still land on a third-party host
|
|
32
32
|
- Hash fragments starting with `#`
|
|
33
33
|
|
|
34
34
|
Rejected:
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { UNSAFE_URL_CHARS, isSameOriginPath } from '../../../utils/url-safety';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Compact-card class constants — single source of truth for the chat-inline
|
|
3
5
|
* `size='sm'` card frame.
|
|
@@ -73,11 +75,11 @@ const SAFE_URL_SCHEMES = ['http:', 'https:', 'mailto:'];
|
|
|
73
75
|
export function safeHref(url: string | null | undefined): string | null {
|
|
74
76
|
if (!url) return null;
|
|
75
77
|
// Defense in depth: control chars + zero-width / line-separator chars.
|
|
76
|
-
if (
|
|
78
|
+
if (UNSAFE_URL_CHARS.test(url)) return null;
|
|
77
79
|
const trimmed = url.trim();
|
|
78
80
|
if (!trimmed) return null;
|
|
79
|
-
// Pure same-origin path.
|
|
80
|
-
if (trimmed.startsWith('/')
|
|
81
|
+
// Pure same-origin path — RESOLVED, not prefix-tested. See `isSameOriginPath`.
|
|
82
|
+
if (trimmed.startsWith('/')) return isSameOriginPath(trimmed) ? trimmed : null;
|
|
81
83
|
if (trimmed.startsWith('#')) return trimmed;
|
|
82
84
|
// Reject bare scheme-only inputs.
|
|
83
85
|
if (/^[a-z][a-z0-9+.-]*:$/i.test(trimmed)) return null;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { type FC, forwardRef, useRef } from 'react';
|
|
2
2
|
import type { LogsListProps, LogEntry } from '../types/logs.types';
|
|
3
3
|
import { cn } from '../utils/cn';
|
|
4
|
+
import { formatDateTimeYmd } from '../utils/format';
|
|
4
5
|
import { LogSeverityDot } from './log-severity-dot';
|
|
5
6
|
import { ToolIcon } from './tool-icon';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// UTC getters so the timestamp is identical on server (UTC) and client
|
|
11
|
-
// (local) — otherwise React #418 hydration mismatch.
|
|
12
|
-
const year = date.getUTCFullYear();
|
|
13
|
-
const month = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
14
|
-
const day = String(date.getUTCDate()).padStart(2, '0');
|
|
15
|
-
const hours = String(date.getUTCHours()).padStart(2, '0');
|
|
16
|
-
const minutes = String(date.getUTCMinutes()).padStart(2, '0');
|
|
17
|
-
|
|
18
|
-
return `${year}/${month}/${day},${hours}:${minutes}`;
|
|
19
|
-
};
|
|
8
|
+
// UTC-pinned so the server and every client agree (React #418), through the one
|
|
9
|
+
// renderer rather than hand-built `getUTC*` strings.
|
|
10
|
+
const formatTimestamp = (timestamp: string | Date): string => formatDateTimeYmd(timestamp, null, { separator: ',' });
|
|
20
11
|
|
|
21
12
|
const LogCard: FC<{
|
|
22
13
|
log: LogEntry;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type { BookingConfirmation } from '../../schemas/meeting-booking-schema';
|
|
4
|
-
import { formatDurationCompact } from '../../utils/format';
|
|
4
|
+
import { formatDurationCompact, formatDateWithTimezone } from '../../utils/format';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Confirmation — terminal success state after a completed booking. Renders
|
|
@@ -16,15 +16,11 @@ export interface ConfirmationProps {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export function Confirmation({ confirmation, timezone }: ConfirmationProps) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
hour: 'numeric',
|
|
25
|
-
minute: '2-digit',
|
|
26
|
-
timeZoneName: 'short',
|
|
27
|
-
}).format(new Date(confirmation.startTimeMs));
|
|
19
|
+
// The SAME preset as the booking summary beside the slot picker, so the time
|
|
20
|
+
// a visitor picked and the time they are told was booked read identically.
|
|
21
|
+
const when = formatDateWithTimezone(confirmation.startTimeMs, timezone, 'weekdayDateTimeZoned', {
|
|
22
|
+
viewerLocale: true,
|
|
23
|
+
});
|
|
28
24
|
|
|
29
25
|
return (
|
|
30
26
|
<div className="flex flex-1 flex-col items-center justify-center gap-[var(--spacing-system-m)] text-center">
|
|
@@ -27,7 +27,7 @@ import { useIsHydrated } from '../../hooks/ui/use-is-hydrated';
|
|
|
27
27
|
import type { SchedulingLink, SchedulingLinksPayload } from '../../schemas/meeting-booking-schema';
|
|
28
28
|
import { cn } from '../../utils/cn';
|
|
29
29
|
import { contentFetch } from '../../utils/embed-content-fetch';
|
|
30
|
-
import { formatDurationCompact } from '../../utils/format';
|
|
30
|
+
import { formatDurationCompact, formatDateWithTimezone, VIEWER_TIMEZONE } from '../../utils/format';
|
|
31
31
|
import { pageCount } from '../../utils/search-params';
|
|
32
32
|
import { EmptyState } from '../empty-state';
|
|
33
33
|
import { PersistentPaginationWrapper } from '../persistent-pagination';
|
|
@@ -60,17 +60,7 @@ function useNextAvailableLabel(ms: number | null): string | null {
|
|
|
60
60
|
const hydrated = useIsHydrated();
|
|
61
61
|
return useMemo(() => {
|
|
62
62
|
if (!hydrated || ms == null) return null;
|
|
63
|
-
|
|
64
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
65
|
-
weekday: 'short',
|
|
66
|
-
month: 'short',
|
|
67
|
-
day: 'numeric',
|
|
68
|
-
hour: 'numeric',
|
|
69
|
-
minute: '2-digit',
|
|
70
|
-
}).format(new Date(ms));
|
|
71
|
-
} catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
63
|
+
return formatDateWithTimezone(ms, VIEWER_TIMEZONE, 'shortWeekdayDateTime', { viewerLocale: true }) || null;
|
|
74
64
|
}, [hydrated, ms]);
|
|
75
65
|
}
|
|
76
66
|
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
type MeetingHost,
|
|
54
54
|
} from '../../schemas/meeting-booking-schema';
|
|
55
55
|
import { cn } from '../../utils/cn';
|
|
56
|
-
import { formatDurationCompact } from '../../utils/format';
|
|
56
|
+
import { formatDurationCompact, formatDateWithTimezone } from '../../utils/format';
|
|
57
57
|
import { Alert, AlertDescription, Button } from '../ui';
|
|
58
58
|
import { BookingForm, BookingFormSkeleton, DEFAULT_SUBMIT_LABEL, type BookingFormProps } from './booking-form';
|
|
59
59
|
import { Confirmation } from './confirmation';
|
|
@@ -845,16 +845,8 @@ export function HubSpotMeetingScheduler({
|
|
|
845
845
|
RangeError on rather than ignoring. */}
|
|
846
846
|
{selectedSlot != null && durationMs != null && timezone != null && (
|
|
847
847
|
<p className="text-ods-text-primary text-h4">
|
|
848
|
-
{
|
|
849
|
-
|
|
850
|
-
weekday: 'long',
|
|
851
|
-
month: 'long',
|
|
852
|
-
day: 'numeric',
|
|
853
|
-
hour: 'numeric',
|
|
854
|
-
minute: '2-digit',
|
|
855
|
-
timeZoneName: 'short',
|
|
856
|
-
}).format(new Date(selectedSlot))}{' '}
|
|
857
|
-
· {formatDurationCompact(durationMs / 1000)}
|
|
848
|
+
{formatDateWithTimezone(selectedSlot, timezone, 'weekdayDateTimeZoned', { viewerLocale: true })} ·{' '}
|
|
849
|
+
{formatDurationCompact(durationMs / 1000)}
|
|
858
850
|
</p>
|
|
859
851
|
)}
|
|
860
852
|
<DetailsForm
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { ChevronRight } from 'lucide-react';
|
|
4
4
|
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { cn } from '../../utils/cn';
|
|
6
|
+
import { formatDateWithTimezone, formatTimeWithTimezone, VIEWER_TIMEZONE } from '../../utils/format';
|
|
6
7
|
import { MAX_MONTH_OFFSET } from '../../utils/hubspot-meetings-convention';
|
|
7
8
|
import { Button, DatePickerCalendar, Skeleton } from '../ui';
|
|
8
9
|
|
|
@@ -89,7 +90,7 @@ function dateFromDayKey(key: string): Date {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
function timeLabelInZone(ms: number, timeZone: string): string {
|
|
92
|
-
return
|
|
93
|
+
return formatTimeWithTimezone(ms, timeZone, { viewerLocale: true });
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
/**
|
|
@@ -211,7 +212,7 @@ const COLUMN_DIVIDER = 'border-b border-ods-border md:border-b-0 md:border-r lg:
|
|
|
211
212
|
export function monthLabelFor(offset: number): string {
|
|
212
213
|
const now = new Date();
|
|
213
214
|
const month = new Date(now.getFullYear(), now.getMonth() + offset, 1);
|
|
214
|
-
return
|
|
215
|
+
return formatDateWithTimezone(month, VIEWER_TIMEZONE, 'monthYear');
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
/** Nothing is bookable yet — used while a month is still loading. */
|
|
@@ -386,11 +387,7 @@ export function SlotPicker({
|
|
|
386
387
|
<p className={COLUMN_HEADING_CLASS}>
|
|
387
388
|
{/* Format the DAY-KEY itself (plain calendar date) — re-zoning a
|
|
388
389
|
local instant could label an adjacent day. */}
|
|
389
|
-
{
|
|
390
|
-
weekday: 'long',
|
|
391
|
-
month: 'long',
|
|
392
|
-
day: 'numeric',
|
|
393
|
-
}).format(dateFromDayKey(selectedDay))}
|
|
390
|
+
{formatDateWithTimezone(dateFromDayKey(selectedDay), VIEWER_TIMEZONE, 'weekday', { viewerLocale: true })}
|
|
394
391
|
</p>
|
|
395
392
|
<div className={CHIP_GRID_CLASS}>
|
|
396
393
|
{daySlots.map(ms => {
|
|
@@ -29,7 +29,7 @@ import { useChatRuntime } from '../../contexts/chat-runtime-context';
|
|
|
29
29
|
import Image from '../../embed-shims/next-image';
|
|
30
30
|
import Link from '../../embed-shims/next-link';
|
|
31
31
|
import { cn } from '../../utils/cn';
|
|
32
|
-
import { formatBioText } from '../../utils/format';
|
|
32
|
+
import { formatBioText, formatDateWithTimezone } from '../../utils/format';
|
|
33
33
|
import { getProxiedImageUrl } from '../../utils/image-proxy';
|
|
34
34
|
|
|
35
35
|
export interface ArticleAuthorBylineProps {
|
|
@@ -65,18 +65,9 @@ export interface ArticleAuthorBylineProps {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function formatDate(value: string | Date): string {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// renders identical — without it a published_at near a midnight boundary
|
|
72
|
-
// formats to a different day on each side, triggering a React #418 hydration
|
|
73
|
-
// text mismatch. Matches the convention in blog-metadata.tsx / investor-update.
|
|
74
|
-
return d.toLocaleDateString('en-US', {
|
|
75
|
-
month: 'long',
|
|
76
|
-
day: 'numeric',
|
|
77
|
-
year: 'numeric',
|
|
78
|
-
timeZone: 'UTC',
|
|
79
|
-
});
|
|
68
|
+
// A published date is a content date: UTC-pinned through the one renderer, so
|
|
69
|
+
// the server and every client agree on the day (React #418).
|
|
70
|
+
return formatDateWithTimezone(value, null, 'long');
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
export function ArticleAuthorByline({
|
|
@@ -22,6 +22,7 @@ A full-featured drawer component built on Radix UI's Dialog primitive, providing
|
|
|
22
22
|
|---|---|---|---|
|
|
23
23
|
| `side` | `"right" \| "left" \| "top" \| "bottom"` | `"right"` | Slide direction |
|
|
24
24
|
| `flush` | `boolean` | `false` | Full-bleed on mobile; floating card on desktop |
|
|
25
|
+
| `size` | `"default" \| "wide"` | `"default"` | Panel size preset; `wide` is 90% of the viewport. Use it instead of a width class. Not combinable with `resizable` (the handle owns the size; a type error) |
|
|
25
26
|
| `resizable` | `boolean` | `false` | Enables drag-to-resize handle |
|
|
26
27
|
| `minSize` | `number` | — | Minimum panel size in px |
|
|
27
28
|
| `maxSize` | `number` | — | Maximum panel size in px (clamped to viewport) |
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { Drawer, DrawerContent, DrawerTitle } from '../drawer';
|
|
4
|
+
|
|
5
|
+
function panelOf(props: { side?: 'right' | 'left' | 'top' | 'bottom'; size?: 'default' | 'wide' }) {
|
|
6
|
+
render(
|
|
7
|
+
<Drawer open>
|
|
8
|
+
<DrawerContent {...props} aria-describedby={undefined}>
|
|
9
|
+
<DrawerTitle>Panel</DrawerTitle>
|
|
10
|
+
</DrawerContent>
|
|
11
|
+
</Drawer>,
|
|
12
|
+
);
|
|
13
|
+
// The title sits in the panel's own tree; the panel is the closest bg-ods-card element.
|
|
14
|
+
return screen.getByText('Panel').closest('.bg-ods-card');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('DrawerContent size', () => {
|
|
18
|
+
it('wide sets the panel to 90% of the viewport width on a side drawer', () => {
|
|
19
|
+
expect(panelOf({ side: 'right', size: 'wide' })).toHaveClass('w-[90vw]');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('wide sets the height on a top or bottom drawer', () => {
|
|
23
|
+
expect(panelOf({ side: 'bottom', size: 'wide' })).toHaveClass('h-[90vh]');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('default adds no size class', () => {
|
|
27
|
+
const panel = panelOf({ side: 'right' });
|
|
28
|
+
expect(panel).not.toHaveClass('w-[90vw]');
|
|
29
|
+
expect(panel).not.toHaveClass('h-[90vh]');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('cannot combine a size preset with the resize handle', () => {
|
|
33
|
+
// Type-level contract: a resizable panel sizes itself inline, so `wide` would be silently dropped.
|
|
34
|
+
// @ts-expect-error size="wide" and resizable are mutually exclusive
|
|
35
|
+
const props: Parameters<typeof DrawerContent>[0] = { size: 'wide', resizable: true };
|
|
36
|
+
expect(props.resizable).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -6,6 +6,7 @@ import { type ReactNode, useCallback, useMemo, useState } from 'react';
|
|
|
6
6
|
import { DayPicker, type DateRange, type DayPickerProps, type Matcher } from 'react-day-picker';
|
|
7
7
|
import { useMdUp } from '../../hooks';
|
|
8
8
|
import { cn } from '../../utils/cn';
|
|
9
|
+
import { formatDateWithTimezone, VIEWER_TIMEZONE } from '../../utils/format';
|
|
9
10
|
import { Button } from './button';
|
|
10
11
|
import { FieldWrapper } from './field-wrapper';
|
|
11
12
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
|
|
@@ -60,13 +61,10 @@ export type DatePickerProps = SingleDatePickerProps | RangeDatePickerProps;
|
|
|
60
61
|
// Helper functions
|
|
61
62
|
// ============================================================================
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
year: 'numeric',
|
|
68
|
-
});
|
|
69
|
-
};
|
|
64
|
+
// A picked date is a LOCAL calendar date (the grid builds it from y/m/d in the
|
|
65
|
+
// browser's zone), so it renders in the viewer's zone — UTC would move it a day
|
|
66
|
+
// for anyone east of Greenwich.
|
|
67
|
+
const defaultFormatDate = (date: Date): string => formatDateWithTimezone(date, VIEWER_TIMEZONE, 'numeric');
|
|
70
68
|
|
|
71
69
|
const formatDateRange = (range: DateRange | undefined, formatFn: (date: Date) => string): string => {
|
|
72
70
|
if (!range?.from) return '';
|
|
@@ -465,12 +463,7 @@ export function DatePickerCalendar({
|
|
|
465
463
|
const handlePreviousMonth = () => shiftMonth(-1);
|
|
466
464
|
const handleNextMonth = () => shiftMonth(1);
|
|
467
465
|
|
|
468
|
-
const formatMonthYear = (date: Date): string =>
|
|
469
|
-
return date.toLocaleDateString('en-US', {
|
|
470
|
-
month: 'long',
|
|
471
|
-
year: 'numeric',
|
|
472
|
-
});
|
|
473
|
-
};
|
|
466
|
+
const formatMonthYear = (date: Date): string => formatDateWithTimezone(date, VIEWER_TIMEZONE, 'monthYear');
|
|
474
467
|
|
|
475
468
|
const getSecondMonth = (date: Date): Date => {
|
|
476
469
|
const next = new Date(date);
|