@flamingo-stack/openframe-frontend-core 0.0.310 → 0.0.311-snapshot.20260623165315
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/{chunk-AIHM4TT7.cjs → chunk-52MEECZB.cjs} +5 -5
- package/dist/{chunk-AIHM4TT7.cjs.map → chunk-52MEECZB.cjs.map} +1 -1
- package/dist/{chunk-2YYAKVL7.cjs → chunk-64JGK22Q.cjs} +50 -30
- package/dist/chunk-64JGK22Q.cjs.map +1 -0
- package/dist/{chunk-4RHOLPFU.cjs → chunk-6GKJXZZM.cjs} +14 -14
- package/dist/{chunk-4RHOLPFU.cjs.map → chunk-6GKJXZZM.cjs.map} +1 -1
- package/dist/{chunk-PLFQJ5E7.cjs → chunk-7G7QJNLY.cjs} +37 -37
- package/dist/{chunk-PLFQJ5E7.cjs.map → chunk-7G7QJNLY.cjs.map} +1 -1
- package/dist/{chunk-CKFHYXSJ.cjs → chunk-7KKIACLD.cjs} +7 -7
- package/dist/{chunk-CKFHYXSJ.cjs.map → chunk-7KKIACLD.cjs.map} +1 -1
- package/dist/{chunk-6RMANFX7.cjs → chunk-AHVG5CFA.cjs} +30 -30
- package/dist/{chunk-6RMANFX7.cjs.map → chunk-AHVG5CFA.cjs.map} +1 -1
- package/dist/{chunk-5OFBD6EQ.js → chunk-BX4MDVBL.js} +40 -20
- package/dist/chunk-BX4MDVBL.js.map +1 -0
- package/dist/{chunk-6SBJVDH3.js → chunk-CGR2DPPQ.js} +4 -4
- package/dist/{chunk-N3YPIZBH.js → chunk-DJBMLHN7.js} +2 -2
- package/dist/{chunk-WSEK6W4B.js → chunk-F45P357Q.js} +2 -2
- package/dist/{chunk-46KRPHHL.js → chunk-GRBFBBSX.js} +2 -2
- package/dist/{chunk-QPTJOLAP.js → chunk-GZPOUZAY.js} +2 -2
- package/dist/{chunk-E7FIV5LH.js → chunk-IHCOTCIG.js} +2 -2
- package/dist/{chunk-ER4CMF47.js → chunk-MI6TET5N.js} +56 -34
- package/dist/chunk-MI6TET5N.js.map +1 -0
- package/dist/{chunk-6TRTIHGW.cjs → chunk-NQDC366J.cjs} +110 -88
- package/dist/chunk-NQDC366J.cjs.map +1 -0
- package/dist/{chunk-QWMYOUGP.js → chunk-PH2RLC4E.js} +2 -2
- package/dist/{chunk-4RI7S6ZD.cjs → chunk-SPFV5TFS.cjs} +9 -9
- package/dist/{chunk-4RI7S6ZD.cjs.map → chunk-SPFV5TFS.cjs.map} +1 -1
- package/dist/{chunk-J3YKVLQ5.cjs → chunk-UFJVTOGS.cjs} +26 -26
- package/dist/{chunk-J3YKVLQ5.cjs.map → chunk-UFJVTOGS.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +8 -8
- package/dist/components/case-studies/index.js +2 -2
- package/dist/components/chart.d.ts +1 -1
- package/dist/components/chat/entity-cards/program-card.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/types/entities/investor-update.d.ts.map +1 -1
- package/dist/components/chat/utils/execute-navigation.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +3 -3
- package/dist/components/contact/index.js +2 -2
- package/dist/components/docs/index.cjs +5 -5
- package/dist/components/docs/index.js +4 -4
- package/dist/components/embeds/index.cjs +3 -3
- package/dist/components/embeds/index.js +2 -2
- package/dist/components/faq/faq-document-page.d.ts +39 -3
- package/dist/components/faq/faq-document-page.d.ts.map +1 -1
- package/dist/components/faq/faq-section.d.ts.map +1 -1
- package/dist/components/faq/index.cjs +3 -3
- package/dist/components/faq/index.js +2 -2
- package/dist/components/features/index.cjs +2 -2
- package/dist/components/features/index.js +1 -1
- package/dist/components/index.cjs +172 -172
- package/dist/components/index.js +8 -8
- package/dist/components/logs-list.d.ts.map +1 -1
- package/dist/components/navigation/index.cjs +2 -2
- package/dist/components/navigation/index.js +1 -1
- package/dist/components/onboarding-guides/index.cjs +23 -23
- package/dist/components/onboarding-guides/index.js +3 -3
- package/dist/components/related-content/index.cjs +3 -3
- package/dist/components/related-content/index.js +2 -2
- package/dist/components/tickets/index.cjs +60 -60
- package/dist/components/tickets/index.js +3 -3
- package/dist/components/ui/device-card.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +2 -2
- package/dist/components/ui/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/utils/date-utils.d.ts.map +1 -1
- package/dist/utils/format.d.ts +12 -3
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/index.cjs +26 -14
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js +26 -14
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/entity-cards/blog-card.tsx +2 -2
- package/src/components/chat/entity-cards/dispatch.tsx +1 -1
- package/src/components/chat/entity-cards/program-card.tsx +17 -4
- package/src/components/chat/types/entities/investor-update.ts +2 -0
- package/src/components/chat/utils/execute-navigation.ts +15 -1
- package/src/components/faq/faq-document-page.tsx +78 -19
- package/src/components/faq/faq-section.tsx +23 -8
- package/src/components/logs-list.tsx +8 -6
- package/src/components/ui/device-card.tsx +8 -6
- package/src/utils/date-utils.ts +27 -14
- package/src/utils/format.ts +27 -8
- package/dist/chunk-2YYAKVL7.cjs.map +0 -1
- package/dist/chunk-5OFBD6EQ.js.map +0 -1
- package/dist/chunk-6TRTIHGW.cjs.map +0 -1
- package/dist/chunk-ER4CMF47.js.map +0 -1
- /package/dist/{chunk-6SBJVDH3.js.map → chunk-CGR2DPPQ.js.map} +0 -0
- /package/dist/{chunk-N3YPIZBH.js.map → chunk-DJBMLHN7.js.map} +0 -0
- /package/dist/{chunk-WSEK6W4B.js.map → chunk-F45P357Q.js.map} +0 -0
- /package/dist/{chunk-46KRPHHL.js.map → chunk-GRBFBBSX.js.map} +0 -0
- /package/dist/{chunk-QPTJOLAP.js.map → chunk-GZPOUZAY.js.map} +0 -0
- /package/dist/{chunk-E7FIV5LH.js.map → chunk-IHCOTCIG.js.map} +0 -0
- /package/dist/{chunk-QWMYOUGP.js.map → chunk-PH2RLC4E.js.map} +0 -0
package/package.json
CHANGED
|
@@ -129,7 +129,7 @@ export function BlogCard({
|
|
|
129
129
|
|
|
130
130
|
if (size === 'sm') {
|
|
131
131
|
const dateStr = post.published_at
|
|
132
|
-
? new Date(post.published_at).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })
|
|
132
|
+
? new Date(post.published_at).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' })
|
|
133
133
|
: ''
|
|
134
134
|
const firstCategory = post.categories?.find((c) => c && c.name)?.name
|
|
135
135
|
return (
|
|
@@ -179,7 +179,7 @@ export function BlogCard({
|
|
|
179
179
|
|
|
180
180
|
// Default: full vertical card.
|
|
181
181
|
const dateStr = post.published_at
|
|
182
|
-
? new Date(post.published_at).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })
|
|
182
|
+
? new Date(post.published_at).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', timeZone: 'UTC' })
|
|
183
183
|
: ''
|
|
184
184
|
return (
|
|
185
185
|
<article
|
|
@@ -893,7 +893,7 @@ function ProgramChatCard({
|
|
|
893
893
|
) {
|
|
894
894
|
typeMeta = item.location_name
|
|
895
895
|
} else if (configKey === 'webinar' && item?.start_at) {
|
|
896
|
-
const time = formatTimeWithTimezone(item.start_at, null)
|
|
896
|
+
const time = formatTimeWithTimezone(item.start_at, item.timezone ?? null)
|
|
897
897
|
const dur = formatDurationFromRange(item.start_at, item.end_at)
|
|
898
898
|
typeMeta = dur ? `${time} · ${dur}` : time
|
|
899
899
|
}
|
|
@@ -45,6 +45,19 @@ import { useEntityCardPlaceholder } from './use-entity-card-placeholder'
|
|
|
45
45
|
|
|
46
46
|
type CardSize = 'default' | 'sm'
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Format a Date with date-fns pinned to UTC. `date-fns` `format()` reads the
|
|
50
|
+
* runtime's LOCAL wall-clock, so the same instant renders differently on the
|
|
51
|
+
* server (Vercel = UTC) and the client (visitor tz) → React #418 hydration
|
|
52
|
+
* mismatch. Shifting by the local offset before formatting emits the UTC
|
|
53
|
+
* wall-clock on every machine, so server and client agree. Mirrors the helper
|
|
54
|
+
* in the hub's `program-header.tsx` (kept local — the lib has no date-fns-tz
|
|
55
|
+
* dep) and the repo-wide "pin program dates to UTC" convention.
|
|
56
|
+
*/
|
|
57
|
+
function formatUtc(date: Date, fmt: string): string {
|
|
58
|
+
return format(new Date(date.getTime() + date.getTimezoneOffset() * 60_000), fmt)
|
|
59
|
+
}
|
|
60
|
+
|
|
48
61
|
export function ProgramCardSkeleton({ size = 'default' }: { size?: CardSize }) {
|
|
49
62
|
if (size === 'sm') {
|
|
50
63
|
return (
|
|
@@ -226,7 +239,7 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
226
239
|
|
|
227
240
|
if (size === 'sm') {
|
|
228
241
|
const itemDate = (() => {
|
|
229
|
-
try { return
|
|
242
|
+
try { return formatUtc(new Date(item.date), 'MMM d, yyyy') } catch { return '' }
|
|
230
243
|
})()
|
|
231
244
|
const compactCover = coverImage || placeholderUrl || null
|
|
232
245
|
let typeMeta: string | null = null
|
|
@@ -238,7 +251,7 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
238
251
|
if (typeof loc === 'string' && loc.trim().length > 0) typeMeta = loc
|
|
239
252
|
} else if (config.type === 'webinar' && 'start_at' in item) {
|
|
240
253
|
const w = item as any
|
|
241
|
-
const time = formatTimeWithTimezone(w.start_at, null)
|
|
254
|
+
const time = formatTimeWithTimezone(w.start_at, w.timezone ?? null)
|
|
242
255
|
const dur = formatDurationFromRange(w.start_at, w.end_at)
|
|
243
256
|
typeMeta = dur ? `${time} · ${dur}` : time
|
|
244
257
|
}
|
|
@@ -293,7 +306,7 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
293
306
|
}
|
|
294
307
|
|
|
295
308
|
const itemDate = new Date(item.date)
|
|
296
|
-
const dateFormat =
|
|
309
|
+
const dateFormat = formatUtc(itemDate, 'EEEE d MMMM')
|
|
297
310
|
|
|
298
311
|
const defaultRenderMeta = () => {
|
|
299
312
|
if (config.type === 'podcast' && 'duration_seconds' in item && !isScheduled) {
|
|
@@ -320,7 +333,7 @@ export function ProgramCard<T extends BaseProgramItem>({
|
|
|
320
333
|
<>
|
|
321
334
|
<Video className="w-4 h-4 text-ods-text-secondary" />
|
|
322
335
|
<span className="font-['DM_Sans'] text-ods-text-secondary">
|
|
323
|
-
{formatTimeWithTimezone(webinarItem.start_at, null)}
|
|
336
|
+
{formatTimeWithTimezone(webinarItem.start_at, webinarItem.timezone ?? null)}
|
|
324
337
|
{duration && ` · ${duration}`}
|
|
325
338
|
</span>
|
|
326
339
|
{webinarItem.timezone && (
|
|
@@ -93,6 +93,8 @@ export function formatInvestorUpdatePeriod(
|
|
|
93
93
|
new Date(d).toLocaleDateString('en-US', {
|
|
94
94
|
month: options?.monthFormat || 'short',
|
|
95
95
|
year: 'numeric',
|
|
96
|
+
// Pin to UTC so SSR (Vercel = UTC) and the client agree (React #418).
|
|
97
|
+
timeZone: 'UTC',
|
|
96
98
|
});
|
|
97
99
|
const s = start ? fmt(start) : '?';
|
|
98
100
|
const e = end ? fmt(end) : '?';
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
import { computeIsNewTab } from './nav-anchor-props'
|
|
32
32
|
import { NEW_TAB_FEATURES, stripSameOriginToPath } from './chat-nav-resolution'
|
|
33
|
+
import { navigateSamePageHash, STICKY_HEADER_OFFSET_PX } from '../../../utils/same-page-hash-nav'
|
|
33
34
|
import type { ChatRuntime } from '../../../contexts/chat-runtime-context'
|
|
34
35
|
|
|
35
36
|
/** Minimal mouse-event surface — structural so chip buttons / tiles can call it
|
|
@@ -77,9 +78,22 @@ function runNavigation(
|
|
|
77
78
|
else window.open(href, '_blank', NEW_TAB_FEATURES)
|
|
78
79
|
return
|
|
79
80
|
}
|
|
81
|
+
const target = stripSameOriginToPath(href)
|
|
82
|
+
// Same-page hash target (e.g. a chat card deep-linking to `/faqs#faq-item-49`):
|
|
83
|
+
// route through the UNIFIED same-page-hash primitive FIRST. A host router /
|
|
84
|
+
// `router.push` performs `pushState`, which the HTML spec says does NOT fire a
|
|
85
|
+
// `hashchange` event — so URL-hash-bound listeners (FAQ auto-expand,
|
|
86
|
+
// `useScrollToHash`) never react on a SOFT same-page nav and the cited row
|
|
87
|
+
// neither opens nor scrolls. `navigateSamePageHash` does the pushState AND
|
|
88
|
+
// dispatches the synthetic `hashchange` (+ anchoring-proof scroll). It returns
|
|
89
|
+
// false for cross-page targets (different pathname/search) — those fall through
|
|
90
|
+
// to the host nav / router below, which mount the new route where the hash is
|
|
91
|
+
// read fresh on first render.
|
|
92
|
+
if (target.includes('#') && navigateSamePageHash(target, { headerOffset: STICKY_HEADER_OFFSET_PX })) {
|
|
93
|
+
return
|
|
94
|
+
}
|
|
80
95
|
const handled = runtime?.navigation.navigate?.({ href, path, targetPlatform }) ?? false
|
|
81
96
|
if (!handled) {
|
|
82
|
-
const target = stripSameOriginToPath(href)
|
|
83
97
|
if (fallbackNavigate) fallbackNavigate(target)
|
|
84
98
|
else window.location.assign(target)
|
|
85
99
|
}
|
|
@@ -2,27 +2,55 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* FaqDocumentPage — the full `/faqs` page with chrome, so embedders drop in
|
|
5
|
-
* ONE component instead of hand-assembling `PageShell` + `PageLayout`
|
|
6
|
-
* bare `<FaqSection>`. Mirrors `LegalDocumentPage` /
|
|
7
|
-
* page-level layout lives in the lib, the host
|
|
5
|
+
* ONE component instead of hand-assembling `PageShell` + `PageLayout` + the
|
|
6
|
+
* FAQ hero around the bare `<FaqSection>`. Mirrors `LegalDocumentPage` /
|
|
7
|
+
* `DevSectionPage`: the page-level layout lives in the lib, the host page is a
|
|
8
|
+
* thin wrapper that passes only config + the SSR-resolved data.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `
|
|
10
|
+
* HERO: renders the canonical FAQ hero (`<h1 class="text-h1">` + accent dot +
|
|
11
|
+
* icon + clamped subtitle) — byte-identical to the multi-platform hub's local
|
|
12
|
+
* `PageWithHeader` chrome the standalone `/faqs` page historically used. It
|
|
13
|
+
* does NOT route through `PageLayout`'s `title`/`subtitle` (the FROZEN
|
|
14
|
+
* `text-h2` `TitleBlock` is a different, smaller header used by OpenFrame
|
|
15
|
+
* detail surfaces). The page owns the `<h1>`, so `<FaqSection heading={null}>`
|
|
16
|
+
* nests its category headings as `<h2>` and the questions as `<h3>` (the
|
|
17
|
+
* SEO-recommended FAQ document outline).
|
|
18
|
+
*
|
|
19
|
+
* DATA: pass `initialFaqs` (SSR-resolved, platform-scoped) so `FaqSection`
|
|
20
|
+
* skips its client self-fetch — the standalone page's static platform-only
|
|
21
|
+
* contract. Omit it for embeds that want the self-fetching `/api/faqs`
|
|
22
|
+
* suggestion-fill instead.
|
|
12
23
|
*/
|
|
13
24
|
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import { HelpCircle } from 'lucide-react';
|
|
27
|
+
import type { Faq } from '../../types/faq';
|
|
14
28
|
import { PageShell, PageLayout } from '../ui';
|
|
15
29
|
import { useRouter } from '../../embed-shims/next-navigation';
|
|
30
|
+
import { SECTION_HERO_ICON_CLASS } from '../../utils/page-header-constants';
|
|
16
31
|
import { FaqSection } from './faq-section';
|
|
32
|
+
import type { FaqSchemaOptions } from './json-ld';
|
|
17
33
|
|
|
18
34
|
export interface FaqDocumentPageProps {
|
|
19
|
-
/**
|
|
35
|
+
/** Hero `<h1>`. Default "Frequently Asked Questions". */
|
|
20
36
|
title?: string;
|
|
21
|
-
/** Subtitle under the title. */
|
|
37
|
+
/** Subtitle under the title (auto-clamped to 2 lines). */
|
|
22
38
|
subtitle?: string;
|
|
39
|
+
/** Icon rendered before the title. Default `<HelpCircle>` (the FAQ glyph). */
|
|
40
|
+
titleIcon?: React.ReactNode;
|
|
41
|
+
/** Render the yellow accent dot after the title (default true). */
|
|
42
|
+
accentDot?: boolean;
|
|
23
43
|
/** Back-button config — same pattern as `DevSectionPage` / `LegalDocumentPage`.
|
|
24
44
|
* Pass `false` to hide. Default `{ label: 'Back to home', href: '/' }`. */
|
|
25
45
|
backButton?: { label?: string; href?: string } | false;
|
|
46
|
+
/** SSR-hydrate `FaqSection` (skips the client fetch — the platform-only
|
|
47
|
+
* contract for the standalone page). Omit for self-fetching embeds. */
|
|
48
|
+
initialFaqs?: Faq[];
|
|
49
|
+
/** Emit FAQPage schema.org JSON-LD (forwarded to `FaqSection`). Off by
|
|
50
|
+
* default so embeds don't emit duplicate schema. */
|
|
51
|
+
emitJsonLd?: boolean;
|
|
52
|
+
/** JSON-LD name/description/url overrides (forwarded to `FaqSection`). */
|
|
53
|
+
jsonLd?: FaqSchemaOptions;
|
|
26
54
|
/** Base URL `FaqSection` appends `/api/faqs` to (reverse-proxy embedders). */
|
|
27
55
|
apiBaseUrl?: string;
|
|
28
56
|
/** Optional entity scoping forwarded to `FaqSection`. */
|
|
@@ -33,9 +61,14 @@ export interface FaqDocumentPageProps {
|
|
|
33
61
|
}
|
|
34
62
|
|
|
35
63
|
export function FaqDocumentPage({
|
|
36
|
-
title = '
|
|
64
|
+
title = 'Frequently Asked Questions',
|
|
37
65
|
subtitle,
|
|
66
|
+
titleIcon = <HelpCircle className={SECTION_HERO_ICON_CLASS} />,
|
|
67
|
+
accentDot = true,
|
|
38
68
|
backButton,
|
|
69
|
+
initialFaqs,
|
|
70
|
+
emitJsonLd,
|
|
71
|
+
jsonLd,
|
|
39
72
|
apiBaseUrl,
|
|
40
73
|
entityType,
|
|
41
74
|
entityId,
|
|
@@ -43,8 +76,9 @@ export function FaqDocumentPage({
|
|
|
43
76
|
}: FaqDocumentPageProps) {
|
|
44
77
|
const router = useRouter();
|
|
45
78
|
|
|
46
|
-
// Back-button config — mirrors LegalDocumentPage/DevSectionPage. Hide
|
|
47
|
-
// when the caller passes `false` (embed-mode where the host owns
|
|
79
|
+
// Back-button config — mirrors LegalDocumentPage / DevSectionPage. Hide
|
|
80
|
+
// entirely when the caller passes `false` (embed-mode where the host owns
|
|
81
|
+
// nav chrome).
|
|
48
82
|
const backCfg =
|
|
49
83
|
backButton === false
|
|
50
84
|
? undefined
|
|
@@ -55,14 +89,39 @@ export function FaqDocumentPage({
|
|
|
55
89
|
|
|
56
90
|
return (
|
|
57
91
|
<PageShell>
|
|
58
|
-
<PageLayout
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
92
|
+
<PageLayout backButton={backCfg}>
|
|
93
|
+
<div className="w-full flex flex-col gap-10">
|
|
94
|
+
{/* Canonical FAQ hero — the exact DOM/CSS the hub's local
|
|
95
|
+
`PageWithHeader` rendered (text-h1 + accent dot + icon + clamped
|
|
96
|
+
subtitle), inlined here so the standalone `/faqs` look is owned by
|
|
97
|
+
the lib. Intentionally NOT the frozen `text-h2` `TitleBlock`. */}
|
|
98
|
+
<div className="flex items-end justify-between gap-[var(--spacing-system-m)] md:flex-col md:items-start md:justify-start lg:flex-row lg:items-end lg:justify-between">
|
|
99
|
+
<div className="flex flex-col gap-[var(--spacing-system-xs)] flex-1 min-w-0">
|
|
100
|
+
<div className="space-y-4">
|
|
101
|
+
<h1 className="text-h1 tracking-[-1.12px] text-ods-text-primary flex items-center gap-3">
|
|
102
|
+
{titleIcon}
|
|
103
|
+
<span>
|
|
104
|
+
{title}
|
|
105
|
+
{accentDot && <span className="text-ods-accent">.</span>}
|
|
106
|
+
</span>
|
|
107
|
+
</h1>
|
|
108
|
+
<p className="font-['DM_Sans'] font-medium text-[18px] leading-[28px] text-ods-text-secondary max-w-3xl line-clamp-2 min-h-[56px]">
|
|
109
|
+
{subtitle || ' '}
|
|
110
|
+
</p>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
<FaqSection
|
|
115
|
+
initialFaqs={initialFaqs}
|
|
116
|
+
heading={null}
|
|
117
|
+
emitJsonLd={emitJsonLd}
|
|
118
|
+
jsonLd={jsonLd}
|
|
119
|
+
apiBaseUrl={apiBaseUrl}
|
|
120
|
+
entityType={entityType}
|
|
121
|
+
entityId={entityId}
|
|
122
|
+
minResults={minResults}
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
66
125
|
</PageLayout>
|
|
67
126
|
</PageShell>
|
|
68
127
|
);
|
|
@@ -6,9 +6,9 @@ import { FaqAccordion, type FaqItem } from '../faq-accordion'
|
|
|
6
6
|
import { useSelfFetch } from '../../hooks/use-self-fetch'
|
|
7
7
|
import { buildSuggestionUrl } from '../../utils/suggestion-url'
|
|
8
8
|
import { serializeJsonLd } from '../../utils/common'
|
|
9
|
-
import {
|
|
9
|
+
import { useScrollToHash } from '../../hooks/use-scroll-to-hash'
|
|
10
10
|
import { navigateSamePageHash, STICKY_HEADER_OFFSET_PX } from '../../utils/same-page-hash-nav'
|
|
11
|
-
import { faqSectionSlug,
|
|
11
|
+
import { faqSectionSlug, parseFaqHash, type FaqHashTarget } from '../../utils/faq-anchor'
|
|
12
12
|
import { cn } from '../../utils/cn'
|
|
13
13
|
import { buildFaqJsonLdFromFaqs, type FaqSchemaOptions } from './json-ld'
|
|
14
14
|
import { SECTION_HEADING_CLASS } from '../layout/page-heading'
|
|
@@ -208,13 +208,28 @@ function GroupedFaqList({
|
|
|
208
208
|
const accordionKeySuffix =
|
|
209
209
|
hashTarget?.kind === 'item' ? `item:${hashTarget.rawId}` : 'default'
|
|
210
210
|
|
|
211
|
+
// Unified scroll-to-hash: rAF-polls for the target row (outlasts the SWR self-fetch
|
|
212
|
+
// + Radix accordion expand) and re-fires on `hashchange` — including the synthetic
|
|
213
|
+
// event `navigateSamePageHash` dispatches for a SOFT same-page chat-card nav (a
|
|
214
|
+
// host-router `pushState` fires no `hashchange`). The ready-dep keys off BOTH the
|
|
215
|
+
// loaded `groups` (so a deep-link / refresh scrolls once the self-fetched list
|
|
216
|
+
// mounts) AND `hashTarget` (so a soft nav re-runs the scroll AFTER the re-render
|
|
217
|
+
// that remounts + opens the cited row, landing on its FINAL expanded position
|
|
218
|
+
// instead of racing the uncontrolled accordion's key-remount — the bare-`hashchange`
|
|
219
|
+
// listener alone fires before the remount and lands on the stale closed position).
|
|
220
|
+
const scrollDep =
|
|
221
|
+
`${groups.length}|` +
|
|
222
|
+
(hashTarget?.kind === 'item'
|
|
223
|
+
? `item:${hashTarget.rawId}`
|
|
224
|
+
: hashTarget?.kind === 'section'
|
|
225
|
+
? `section:${hashTarget.slug}`
|
|
226
|
+
: 'none')
|
|
227
|
+
useScrollToHash(scrollDep, { headerOffset: STICKY_HEADER_OFFSET_PX })
|
|
228
|
+
|
|
229
|
+
// A section hash also lights up its category pill; item hashes leave the pills
|
|
230
|
+
// untouched so deep-linking a question never disturbs scroll-spy state.
|
|
211
231
|
useEffect(() => {
|
|
212
|
-
if (
|
|
213
|
-
const elId =
|
|
214
|
-
hashTarget.kind === 'item' ? faqItemAnchor(hashTarget.rawId) : hashTarget.slug
|
|
215
|
-
const el = document.getElementById(elId)
|
|
216
|
-
if (el) scrollElementIntoView(el, { headerOffset: STICKY_HEADER_OFFSET_PX })
|
|
217
|
-
if (hashTarget.kind === 'section') setActiveSlug(hashTarget.slug)
|
|
232
|
+
if (hashTarget?.kind === 'section') setActiveSlug(hashTarget.slug)
|
|
218
233
|
}, [hashTarget])
|
|
219
234
|
|
|
220
235
|
// Category pill click. `navigateSamePageHash` owns the entire transition:
|
|
@@ -7,12 +7,14 @@ import { ToolIcon } from './tool-icon'
|
|
|
7
7
|
const formatTimestamp = (timestamp: string | Date): string => {
|
|
8
8
|
const date = timestamp instanceof Date ? timestamp : new Date(timestamp)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
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
|
+
|
|
16
18
|
return `${year}/${month}/${day},${hours}:${minutes}`
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -66,12 +66,14 @@ export function DeviceCard({
|
|
|
66
66
|
if (!lastSeen) return null
|
|
67
67
|
|
|
68
68
|
const date = typeof lastSeen === 'string' ? new Date(lastSeen) : lastSeen
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
69
|
+
// UTC getters so "last seen" is identical on server (UTC) and client
|
|
70
|
+
// (local) — otherwise React #418 hydration mismatch.
|
|
71
|
+
const year = date.getUTCFullYear()
|
|
72
|
+
const month = String(date.getUTCMonth() + 1).padStart(2, '0')
|
|
73
|
+
const day = String(date.getUTCDate()).padStart(2, '0')
|
|
74
|
+
const hours = String(date.getUTCHours()).padStart(2, '0')
|
|
75
|
+
const minutes = String(date.getUTCMinutes()).padStart(2, '0')
|
|
76
|
+
|
|
75
77
|
return `${year}/${month}/${day}, ${hours}:${minutes}`
|
|
76
78
|
}
|
|
77
79
|
|
package/src/utils/date-utils.ts
CHANGED
|
@@ -17,9 +17,11 @@ export function formatTicketRelativeTime(iso: string): string {
|
|
|
17
17
|
if (diffMin < 60) return `${diffMin} min ago`
|
|
18
18
|
const diffHours = Math.floor(diffMin / 60)
|
|
19
19
|
if (diffHours < 24) return diffHours === 1 ? '1 hour ago' : `${diffHours} hours ago`
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
20
|
+
// UTC getters so the MM/DD/YYYY tail is identical on server (UTC) and client
|
|
21
|
+
// (local) — otherwise React #418 hydration mismatch.
|
|
22
|
+
const mm = String(date.getUTCMonth() + 1).padStart(2, '0')
|
|
23
|
+
const dd = String(date.getUTCDate()).padStart(2, '0')
|
|
24
|
+
const yyyy = date.getUTCFullYear()
|
|
23
25
|
return `${mm}/${dd}/${yyyy}`
|
|
24
26
|
}
|
|
25
27
|
|
|
@@ -29,11 +31,13 @@ export function formatTicketRelativeTime(iso: string): string {
|
|
|
29
31
|
export function formatTicketFullTimestamp(iso: string): string {
|
|
30
32
|
const date = new Date(iso)
|
|
31
33
|
if (Number.isNaN(date.getTime())) return ''
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
34
|
+
// UTC getters so the tooltip timestamp is identical on server (UTC) and
|
|
35
|
+
// client (local) — otherwise React #418 hydration mismatch.
|
|
36
|
+
const mm = String(date.getUTCMonth() + 1).padStart(2, '0')
|
|
37
|
+
const dd = String(date.getUTCDate()).padStart(2, '0')
|
|
38
|
+
const yyyy = date.getUTCFullYear()
|
|
39
|
+
let hours = date.getUTCHours()
|
|
40
|
+
const minutes = String(date.getUTCMinutes()).padStart(2, '0')
|
|
37
41
|
const ampm = hours >= 12 ? 'PM' : 'AM'
|
|
38
42
|
hours = hours % 12 || 12
|
|
39
43
|
return `${mm}/${dd}/${yyyy}, ${hours}:${minutes} ${ampm}`
|
|
@@ -88,11 +92,14 @@ export function formatRelativeTime(timestamp: string | Date): string {
|
|
|
88
92
|
return `${weeks}w ago`;
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
// Older than 30 days - show formatted date
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
// Older than 30 days - show formatted date, pinned to UTC so SSR (UTC) and
|
|
96
|
+
// the client agree (React #418). Year comparison also uses UTC for the same
|
|
97
|
+
// reason (avoids a server/client split right at a year boundary).
|
|
98
|
+
return targetTime.toLocaleDateString('en-US', {
|
|
99
|
+
month: 'short',
|
|
94
100
|
day: 'numeric',
|
|
95
|
-
year: targetTime.
|
|
101
|
+
year: targetTime.getUTCFullYear() !== now.getUTCFullYear() ? 'numeric' : undefined,
|
|
102
|
+
timeZone: 'UTC',
|
|
96
103
|
});
|
|
97
104
|
}
|
|
98
105
|
|
|
@@ -118,9 +125,12 @@ export function formatAbsoluteDate(
|
|
|
118
125
|
year: 'numeric',
|
|
119
126
|
month: 'short',
|
|
120
127
|
day: 'numeric',
|
|
128
|
+
// Pin to UTC so SSR (Vercel = UTC) and the client agree (React #418).
|
|
129
|
+
// Caller can override via `options`.
|
|
130
|
+
timeZone: 'UTC',
|
|
121
131
|
...options
|
|
122
132
|
};
|
|
123
|
-
|
|
133
|
+
|
|
124
134
|
return targetTime.toLocaleDateString('en-US', defaultOptions);
|
|
125
135
|
}
|
|
126
136
|
|
|
@@ -148,9 +158,12 @@ export function formatDateTime(
|
|
|
148
158
|
day: 'numeric',
|
|
149
159
|
hour: 'numeric',
|
|
150
160
|
minute: '2-digit',
|
|
161
|
+
// Pin to UTC so SSR (Vercel = UTC) and the client agree (React #418).
|
|
162
|
+
// Caller can override via `options`.
|
|
163
|
+
timeZone: 'UTC',
|
|
151
164
|
...options
|
|
152
165
|
};
|
|
153
|
-
|
|
166
|
+
|
|
154
167
|
return targetTime.toLocaleDateString('en-US', defaultOptions);
|
|
155
168
|
}
|
|
156
169
|
|
package/src/utils/format.ts
CHANGED
|
@@ -24,7 +24,10 @@ export function formatDate(
|
|
|
24
24
|
return "Invalid Date"
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
// Pin to UTC by default so SSR (Vercel = UTC) and the client agree (React
|
|
28
|
+
// #418 hydration mismatch). A caller can still override by passing its own
|
|
29
|
+
// `timeZone` in `options`.
|
|
30
|
+
return dateObj.toLocaleDateString("en-US", { timeZone: "UTC", ...options })
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
/**
|
|
@@ -223,9 +226,18 @@ export function formatDurationCompact(seconds: number | null | undefined): strin
|
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
/**
|
|
226
|
-
* Format time
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
+
* Format a webinar/event start time as the wall-clock in its OWN timezone.
|
|
230
|
+
*
|
|
231
|
+
* `date` is an instant (UTC timestamp / ISO string). `timezone` is the event's
|
|
232
|
+
* IANA zone (e.g. `'America/New_York'`). Rendering in that explicit zone makes
|
|
233
|
+
* the server (Vercel = UTC) and the visitor's browser emit the SAME text —
|
|
234
|
+
* fixing the React #418 hydration mismatch — AND shows the true event time
|
|
235
|
+
* (4:00 PM EDT, not the 8:00 PM UTC a plain UTC pin would show, nor the
|
|
236
|
+
* viewer-local time the old unpinned call produced). Falls back to UTC when no
|
|
237
|
+
* zone is given, and tolerates a non-IANA label (legacy data) without throwing.
|
|
238
|
+
* The zone LABEL is rendered separately by callers, so it is never appended here.
|
|
239
|
+
*
|
|
240
|
+
* Returns: "4:00 PM"
|
|
229
241
|
*/
|
|
230
242
|
export function formatTimeWithTimezone(
|
|
231
243
|
date: Date | string | null | undefined,
|
|
@@ -234,13 +246,20 @@ export function formatTimeWithTimezone(
|
|
|
234
246
|
if (!date) return '';
|
|
235
247
|
|
|
236
248
|
const dateObj = typeof date === 'string' ? new Date(date) : date;
|
|
237
|
-
const
|
|
249
|
+
const opts: Intl.DateTimeFormatOptions = {
|
|
238
250
|
hour: 'numeric',
|
|
239
251
|
minute: '2-digit',
|
|
240
252
|
hour12: true,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
253
|
+
timeZone: timezone || 'UTC',
|
|
254
|
+
};
|
|
255
|
+
try {
|
|
256
|
+
return dateObj.toLocaleTimeString('en-US', opts);
|
|
257
|
+
} catch {
|
|
258
|
+
// Non-IANA `timezone` (e.g. a bare "EST" label) makes Intl throw a
|
|
259
|
+
// RangeError. Fall back to a UTC-pinned render so we stay deterministic
|
|
260
|
+
// (still no #418) instead of crashing.
|
|
261
|
+
return dateObj.toLocaleTimeString('en-US', { ...opts, timeZone: 'UTC' });
|
|
262
|
+
}
|
|
244
263
|
}
|
|
245
264
|
|
|
246
265
|
/**
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-2YYAKVL7.cjs","../src/components/faq/faq-section.tsx","../src/components/faq-accordion.tsx","../src/components/faq/json-ld.ts","../src/components/faq/faq-document-page.tsx"],"names":["jsx","jsxs"],"mappings":"AAAA,6rBAAY;AACZ;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;AC3BA,8BAAiE;AD6BjE;AACA;AE9BA;AAEA,uCAAA,CAAA;AAoEY,+CAAA;AArDZ,IAAM,kBAAA,EAAoB,CAAC,MAAA,EAAA,GAAoB;AAC7C,EAAA,MAAM,IAAA,EAAM,2BAAA,IAAkC,CAAA;AAC9C,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,EAAA,EAAI,6BAAA,KAAsB,CAAA;AAExD,EAAA,MAAM,QAAA,EAAU,gCAAA,CAAY,EAAA,GAAM;AAChC,IAAA,GAAA,CAAI,GAAA,CAAI,OAAA,EAAS;AACf,MAAA,MAAM,OAAA,EAAS,GAAA,CAAI,OAAA,CAAQ,YAAA;AAC3B,MAAA,YAAA,CAAa,CAAA,EAAA;AACf,IAAA;AACG,EAAA;AAGW,EAAA;AACF,IAAA;AACF,MAAA;AACH,IAAA;AACQ,MAAA;AACf,IAAA;AACU,EAAA;AAEE,EAAA;AAChB;AAEgB;AACE,EAAA;AAEA,EAAA;AACH,IAAA;AACI,MAAA;AACA,MAAA;AACC,MAAA;AACP,MAAA;AACR,IAAA;AACH,EAAA;AAGE,EAAA;AAEmB,IAAA;AACF,IAAA;AAGX,IAAA;AAAC,MAAA;AAAA,MAAA;AAOK,QAAA;AACO,QAAA;AAGX,QAAA;AAAA,0BAAA;AAAC,YAAA;AAAA,YAAA;AACM,cAAA;AACL,cAAA;AACA,cAAA;AACA,cAAA;AACM,gBAAA;AACA,kBAAA;AACF,kBAAA;AACF,gBAAA;AACF,cAAA;AACA,cAAA;AACA,cAAA;AAEA,cAAA;AAAA,gCAAA;AAKA,gCAAA;AACG,kBAAA;AAAA,kBAAA;AACC,oBAAA;AACA,oBAAA;AACA,oBAAA;AACA,oBAAA;AACA,oBAAA;AAAY,kBAAA;AAEhB,gBAAA;AAAA,cAAA;AAAA,YAAA;AACF,UAAA;AAEA,0BAAA;AAAC,YAAA;AAAA,YAAA;AACC,cAAA;AACA,cAAA;AAMA,cAAA;AAEA,YAAA;AACF,UAAA;AAAA,QAAA;AAAA,MAAA;AAlDU,MAAA;AAmDZ,IAAA;AAGN,EAAA;AAEJ;AFFoB;AACA;AC1GpB;AD4GoB;AACA;AGtGC;AACf;AAGU;AACP,EAAA;AACO,IAAA;AACH,IAAA;AACE,IAAA;AACE,IAAA;AACI,IAAA;AACnB,EAAA;AACF;AAEgB;AACP,EAAA;AACF,IAAA;AACS,IAAA;AACD,MAAA;AACC,MAAA;AACV,MAAA;AACW,QAAA;AACC,QAAA;AACZ,MAAA;AACA,IAAA;AACJ,EAAA;AACF;AHqGoB;AACA;AC2GN;AA5MR;AAKG;AAMA,EAAA;AACT;AAcS;AACkB,EAAA;AACV,EAAA;AACX,EAAA;AACc,EAAA;AACQ,IAAA;AACX,IAAA;AACF,IAAA;AACJ,MAAA;AACS,MAAA;AACd,MAAA;AACF,IAAA;AACY,IAAA;AACA,IAAA;AACA,MAAA;AACC,MAAA;AACA,MAAA;AACb,IAAA;AACY,IAAA;AACd,EAAA;AACe,EAAA;AACI,EAAA;AACZ,EAAA;AACT;AAMM;AACY;AAYT;AACP,EAAA;AACA,EAAA;AASC;AACK,EAAA;AACY,EAAA;AACX,EAAA;AAGS,EAAA;AAMA,EAAA;AACA,IAAA;AACD,IAAA;AACP,IAAA;AACS,MAAA;AACA,QAAA;AACH,UAAA;AACI,UAAA;AACA,UAAA;AACZ,QAAA;AACI,QAAA;AACA,QAAA;AACQ,QAAA;AACA,UAAA;AACR,YAAA;AACA,YAAA;AACF,UAAA;AACF,QAAA;AACY,QAAA;AACd,MAAA;AACc,MAAA;AAChB,IAAA;AACW,IAAA;AACE,MAAA;AACH,MAAA;AACV,IAAA;AACa,IAAA;AAGH,EAAA;AAYL,EAAA;AACS,EAAA;AACE,IAAA;AACR,IAAA;AACD,IAAA;AACM,IAAA;AACV,EAAA;AAIC,EAAA;AACY,IAAA;AACV,IAAA;AACS,IAAA;AACJ,IAAA;AACG,MAAA;AACH,MAAA;AACX,IAAA;AACc,IAAA;AACJ,EAAA;AAON,EAAA;AAGU,EAAA;AACG,IAAA;AAEf,IAAA;AACS,IAAA;AACH,IAAA;AACO,IAAA;AACF,EAAA;AAkBT,EAAA;AACsD,IAAA;AACtD,MAAA;AACF,MAAA;AACE,QAAA;AACS,QAAA;AACV,MAAA;AACH,IAAA;AACC,IAAA;AACH,EAAA;AAGE,EAAA;AACa,IAAA;AAGC,MAAA;AAEJ,MAAA;AAAC,QAAA;AAAA,QAAA;AAEW,UAAA;AACV,UAAA;AACU,UAAA;AACV,UAAA;AACE,YAAA;AACA,YAAA;AAGF,UAAA;AAEC,UAAA;AAAM,QAAA;AAXI,QAAA;AAYb,MAAA;AAGN,IAAA;AAEFA,oBAAAA;AAEgB,MAAA;AAEV,MAAA;AAAC,QAAA;AAAA,QAAA;AAEW,UAAA;AACV,UAAA;AAEC,UAAA;AAAM,YAAA;AAGP,4BAAA;AAAC,cAAA;AAAA,cAAA;AAKC,gBAAA;AACA,gBAAA;AAA8C,cAAA;AAFnC,cAAA;AAGb,YAAA;AAAA,UAAA;AAAA,QAAA;AAdK,QAAA;AAeP,MAAA;AAGN,IAAA;AACF,EAAA;AAEJ;AAES;AAEL,EAAA;AACEA,oBAAAA;AACAA,oBAAAA;AAGM,sBAAA;AACA,sBAAA;AAGN,IAAA;AACF,EAAA;AAEJ;AAuB2B;AACzB,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACa,EAAA;AACb,EAAA;AACA,EAAA;AACA,EAAA;AACa,EAAA;AACK;AACN,EAAA;AAGN,EAAA;AACG,IAAA;AACK,IAAA;AACd,EAAA;AACc,EAAA;AAED,EAAA;AAEE,EAAA;AAKT,EAAA;AAKY,EAAA;AACA,EAAA;AACD,EAAA;AAEb,IAAA;AAIJ,EAAA;AAEe,EAAA;AAGb,EAAA;AACEC,oBAAAA;AACG,MAAA;AACD,sBAAA;AACF,IAAA;AAEE,IAAA;AAAC,MAAA;AAAA,MAAA;AACM,QAAA;AAIL,QAAA;AAA2D,MAAA;AAC7D,IAAA;AAEJ,EAAA;AAEJ;ADzDoB;AACA;AIvUpB;AA4CQD;AAxBQ;AACN,EAAA;AACR,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACuB;AACR,EAAA;AAKb,EAAA;AAGa,IAAA;AACQ,IAAA;AACjB,EAAA;AAGJ,EAAA;AAEK,IAAA;AAAA,IAAA;AACU,MAAA;AACT,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AAAA,IAAA;AAGN,EAAA;AAEJ;AJ6SoB;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-2YYAKVL7.cjs","sourcesContent":[null,"\"use client\"\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { Faq } from '../../types/faq'\nimport { FaqAccordion, type FaqItem } from '../faq-accordion'\nimport { useSelfFetch } from '../../hooks/use-self-fetch'\nimport { buildSuggestionUrl } from '../../utils/suggestion-url'\nimport { serializeJsonLd } from '../../utils/common'\nimport { scrollElementIntoView } from '../../utils/scroll-into-view'\nimport { navigateSamePageHash, STICKY_HEADER_OFFSET_PX } from '../../utils/same-page-hash-nav'\nimport { faqSectionSlug, faqItemAnchor, parseFaqHash, type FaqHashTarget } from '../../utils/faq-anchor'\nimport { cn } from '../../utils/cn'\nimport { buildFaqJsonLdFromFaqs, type FaqSchemaOptions } from './json-ld'\nimport { SECTION_HEADING_CLASS } from '../layout/page-heading'\n\nexport interface FaqSectionProps {\n /**\n * SSR hydrate. When provided, the hook skips the first client fetch (per\n * useSelfFetch contract). The consuming server page resolves FAQs then drills\n * them into this prop — the lib never re-fetches what the host already gated on.\n */\n initialFaqs?: Faq[]\n /** Both required together for entity-attached FAQs; partial → bare /api/faqs. */\n entityType?: string\n entityId?: number | string\n /**\n * Heading node above the grouped list. `undefined` → default\n * `<h2>`\"Frequently Asked Questions\". `null` → no heading (the host page\n * owns the `<h1>`, as the standalone /faqs surface does). A React node lets a\n * platform drill its own <PageHeading> without the lib referencing platform\n * state. Also drives category nesting so the document outline stays correct:\n * `null` → categories render `<h2>` (directly under the page `<h1>`);\n * otherwise categories render `<h3>` beneath this heading.\n */\n heading?: React.ReactNode | null\n /** Inject FAQPage schema.org JSON-LD as a <script>. Off by default so embeds\n * don't emit duplicate schema. */\n emitJsonLd?: boolean\n /** Overrides for the JSON-LD's name/description/url. */\n jsonLd?: FaqSchemaOptions\n className?: string\n /** Maps to /api/faqs `?count=` (the 5-tier fill target). Absent → param\n * not sent (server default applies). */\n minResults?: number\n /** Fetch-URL prefix for third-party embeds / reverse proxies\n * ('' = same-origin relative). */\n apiBaseUrl?: string\n}\n\nconst DEFAULT_HEADING_TEXT = 'Frequently Asked Questions'\n\n/** URL composition shared with RelatedContentSection (`buildSuggestionUrl`)\n * — byte-identical to the historical `buildFaqsUrl` output when\n * `minResults`/`apiBaseUrl` are absent. */\nfunction buildFaqsUrl(\n entityType?: string,\n entityId?: number | string,\n minResults?: number,\n apiBaseUrl = '',\n): string {\n return buildSuggestionUrl('/api/faqs', { apiBaseUrl, entityType, entityId, count: minResults })\n}\n\ninterface FaqGroup {\n /** null → the uncategorized bucket: no heading, no jump pill, rendered last. */\n section: string | null\n slug: string | null\n items: FaqItem[]\n}\n\n/** Group FAQs by `faq.section`, preserving the server's first-seen\n * (display_order) order for BOTH the section order and the rows within each\n * section. The uncategorized bucket (blank/missing section) sinks to the end\n * since it renders without a heading. Items carry NO badge here — the `<h2>`\n * IS the category, so a per-row chip would be redundant. */\nfunction groupFaqsBySection(faqs: Faq[]): FaqGroup[] {\n const order: string[] = []\n const byName = new Map<string, FaqGroup>()\n let uncategorized: FaqGroup | null = null\n for (const faq of faqs) {\n const item: FaqItem = { id: faq.id, question: faq.question, answer: faq.answer }\n const name = faq.section?.trim()\n if (!name) {\n if (!uncategorized) uncategorized = { section: null, slug: null, items: [] }\n uncategorized.items.push(item)\n continue\n }\n let group = byName.get(name)\n if (!group) {\n group = { section: name, slug: faqSectionSlug(name), items: [] }\n byName.set(name, group)\n order.push(name)\n }\n group.items.push(item)\n }\n const groups = order.map((name) => byName.get(name)!)\n if (uncategorized) groups.push(uncategorized)\n return groups\n}\n\n\n/** Map key for the uncategorized bucket — `group.slug` is null for it, so\n * every per-group map (default-open ids, accordion keys) uses this sentinel\n * to keep the lookup typed. */\nconst UNCATEGORIZED_KEY = '__uncategorized__'\nconst groupKey = (g: FaqGroup): string => g.slug ?? UNCATEGORIZED_KEY\n\n/**\n * Grouped FAQ layout: a category jump-nav above stacked `<h2>` category\n * sections (each its own accordion). Isolated into its own component so the\n * scroll-spy hooks only mount in grouped mode — `FaqSection`'s own hooks stay\n * unconditional.\n *\n * The pills are real `<a href=\"#slug\">` anchors (crawlable in-page links,\n * deep-linkable, work without JS); the click handler upgrades the jump to the\n * cancellation-proof `scrollElementIntoView` tween and syncs the URL hash.\n */\nfunction GroupedFaqList({\n groups,\n categoryHeadingAs,\n}: {\n groups: FaqGroup[]\n /** Heading tag for each category, so the document outline nests correctly\n * under whatever owns the heading above this block: `h2` on the standalone\n * page (the page owns the `<h1>`), `h3` beneath an embed's `<h2>` title.\n * The VISUAL is `SECTION_HEADING_CLASS` either way, so categories look\n * identical on every surface. */\n categoryHeadingAs: 'h2' | 'h3'\n}) {\n const CategoryHeading = categoryHeadingAs\n const navGroups = useMemo(() => groups.filter((g) => g.slug), [groups])\n const [activeSlug, setActiveSlug] = useState<string | null>(navGroups[0]?.slug ?? null)\n // Identity-stable key for the section set so the observer re-binds only when\n // the categories actually change (not on every parent re-render).\n const slugKey = navGroups.map((g) => g.slug).join('|')\n\n // Scroll-spy: mark the pill for the category currently at the top of the\n // viewport. rootMargin drops the trigger line just below the sticky header\n // and ignores the bottom ~55% so \"active\" is the section being read, not the\n // next one peeking in.\n useEffect(() => {\n if (navGroups.length < 2) return\n const tops = new Map<string, number>()\n const observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n const id = (entry.target as HTMLElement).id\n if (entry.isIntersecting) tops.set(id, entry.boundingClientRect.top)\n else tops.delete(id)\n }\n let bestId: string | null = null\n let bestTop = Number.POSITIVE_INFINITY\n for (const [id, top] of tops) {\n if (top < bestTop) {\n bestTop = top\n bestId = id\n }\n }\n if (bestId) setActiveSlug(bestId)\n },\n { rootMargin: `-${STICKY_HEADER_OFFSET_PX}px 0px -55% 0px`, threshold: 0 },\n )\n for (const group of navGroups) {\n const el = group.slug ? document.getElementById(group.slug) : null\n if (el) observer.observe(el)\n }\n return () => observer.disconnect()\n // slugKey encodes the section set; re-observe only when it changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [slugKey])\n\n // ─── Hash dispatch — `/faqs#faq-item-<id>` or `/faqs#faq-<section-slug>` ──\n // Tracks the current hash so:\n // 1. an item-kind hash seeds `defaultOpenIds` on the matching accordion\n // (auto-expands the cited question);\n // 2. either kind triggers the cancellation-proof tween scroll with the\n // sticky-header offset (native browser hash scroll runs once, ignores\n // our offset — re-running the tween puts the target in the right spot).\n // Listens to `hashchange` so back/forward replays the same behavior. SSR-\n // safe: initial null state matches the server render; the first effect\n // tick on the client updates it.\n const [hashTarget, setHashTarget] = useState<FaqHashTarget | null>(null)\n useEffect(() => {\n const refresh = () => setHashTarget(parseFaqHash(window.location.hash))\n refresh()\n window.addEventListener('hashchange', refresh)\n return () => window.removeEventListener('hashchange', refresh)\n }, [])\n\n // Per-group default-open set when the hash points at an item. The map key\n // matches `groupKey(group)` so the render-time lookup is O(1) per group.\n const defaultOpenByGroupKey = useMemo(() => {\n if (hashTarget?.kind !== 'item') return null\n const targetId = hashTarget.rawId\n const result = new Map<string, (string | number)[]>()\n for (const group of groups) {\n const hit = group.items.find((i) => String(i.id) === targetId)\n if (hit) result.set(groupKey(group), [hit.id])\n }\n return result.size > 0 ? result : null\n }, [groups, hashTarget])\n\n // Accordion is uncontrolled — `defaultOpenIds` is only consumed at mount,\n // so a new item hash needs a remount to honor it. Keying off the item-id\n // suffix triggers exactly the remount we need (and stays stable when the\n // hash points at a section, so category navigation never disturbs the\n // accordion's open state).\n const accordionKeySuffix =\n hashTarget?.kind === 'item' ? `item:${hashTarget.rawId}` : 'default'\n\n useEffect(() => {\n if (!hashTarget) return\n const elId =\n hashTarget.kind === 'item' ? faqItemAnchor(hashTarget.rawId) : hashTarget.slug\n const el = document.getElementById(elId)\n if (el) scrollElementIntoView(el, { headerOffset: STICKY_HEADER_OFFSET_PX })\n if (hashTarget.kind === 'section') setActiveSlug(hashTarget.slug)\n }, [hashTarget])\n\n // Category pill click. `navigateSamePageHash` owns the entire transition:\n // replaceState → synthetic `hashchange` → `scrollElementIntoView` tween\n // with `STICKY_HEADER_OFFSET_PX` so the section heading lands BELOW the\n // sticky category nav on the FIRST tween (covers the same-target\n // re-click case, where the `hashTarget` effect at L214 is a no-op\n // because the state reference is equal). For DIFFERENT-target clicks\n // the helper's synthetic `hashchange` re-fires that effect, which\n // re-scrolls with the same offset and cancels this tween (singleton)\n // — both paths land at the same position. The effect is still\n // required for back/forward + direct URL edits, where the helper\n // isn't in the call chain.\n //\n // `history: 'replace'` matches the pre-helper behavior: category pills\n // are a TOC, not a navigation step, so the Back button leaves the\n // FAQ page in one step regardless of how many categories the user\n // clicked through.\n const handleJump = useCallback(\n (e: React.MouseEvent<HTMLAnchorElement>, slug: string) => {\n e.preventDefault()\n navigateSamePageHash('#' + slug, {\n headerOffset: STICKY_HEADER_OFFSET_PX,\n history: 'replace',\n })\n },\n [],\n )\n\n return (\n <div className=\"space-y-8\">\n {navGroups.length > 1 && (\n <nav aria-label=\"FAQ categories\" className=\"flex flex-wrap gap-2\">\n {navGroups.map((group) => {\n const isActive = group.slug === activeSlug\n return (\n <a\n key={group.slug}\n href={`#${group.slug}`}\n aria-current={isActive ? 'true' : undefined}\n onClick={(e) => handleJump(e, group.slug as string)}\n className={cn(\n \"rounded-full border px-4 py-2 text-sm font-medium font-['DM_Sans'] transition-colors\",\n isActive\n ? 'border-ods-text-primary bg-ods-card text-ods-text-primary'\n : 'border-ods-border bg-ods-card text-ods-text-secondary hover:border-ods-text-secondary hover:text-ods-text-primary',\n )}\n >\n {group.section}\n </a>\n )\n })}\n </nav>\n )}\n <div className=\"space-y-10\">\n {groups.map((group) => {\n const key = groupKey(group)\n return (\n <section\n key={key}\n id={group.slug ?? undefined}\n className=\"scroll-mt-24 space-y-4\"\n >\n {group.section && (\n <CategoryHeading className={SECTION_HEADING_CLASS}>{group.section}</CategoryHeading>\n )}\n <FaqAccordion\n // Re-key on item-hash changes so the remount picks up the new\n // `defaultOpenIds` (the accordion is uncontrolled). Stable for\n // section hashes — category navigation doesn't disturb state.\n key={`${key}:${accordionKeySuffix}`}\n items={group.items}\n defaultOpenIds={defaultOpenByGroupKey?.get(key)}\n />\n </section>\n )\n })}\n </div>\n </div>\n )\n}\n\nfunction FaqSkeleton() {\n return (\n <div className=\"space-y-8 animate-pulse\">\n <div className=\"h-12 md:h-14 w-2/3 rounded bg-ods-border\" />\n <div className=\"rounded-3xl border border-ods-border overflow-hidden bg-ods-card divide-y divide-ods-border w-full\">\n {Array.from({ length: 8 }).map((_, idx) => (\n <div key={idx} className=\"flex items-center justify-between px-6 md:px-8 py-6\">\n <div className=\"h-6 w-5/6 rounded bg-ods-border\" />\n <div className=\"h-10 w-10 rounded-md bg-ods-border\" />\n </div>\n ))}\n </div>\n </div>\n )\n}\n\ninterface FaqsResponse {\n faqs: Faq[]\n}\n\n/**\n * The FAQ display surface — ONE rendering on every host: the list grouped by\n * `faq.section` (each category a heading + its own accordion, with a category\n * jump-nav once there are 2+ categories). There is no flat/ungrouped mode and\n * no page-vs-embedded shell fork; the standalone /faqs page and every embed\n * render through this single path, so they cannot drift.\n *\n * - Standalone /faqs page: pass `initialFaqs` (SSR) + `heading={null}` (the\n * page owns the <h1>) + `emitJsonLd` with `jsonLd` overrides for SEO.\n * - Per-entity embed: pass `entityType` + `entityId` (no `initialFaqs`); the\n * hook self-fetches `GET /api/faqs`, and `heading` is this block's own <h2>.\n *\n * CONTRACT: the consuming app MUST implement `GET /api/faqs`. On a fetch error\n * (or zero FAQs) the component renders nothing so the host page isn't\n * disfigured. The host always supplies the page shell — this renders a bare\n * <section>.\n */\nexport function FaqSection({\n initialFaqs,\n entityType,\n entityId,\n heading,\n emitJsonLd = false,\n jsonLd,\n className,\n minResults,\n apiBaseUrl = '',\n}: FaqSectionProps) {\n const url = buildFaqsUrl(entityType, entityId, minResults, apiBaseUrl)\n // Memoized — useSelfFetch re-syncs on [initialData]; a fresh per-render\n // wrapper object would setState-loop under re-rendering parents.\n const initialData = useMemo<FaqsResponse | undefined>(\n () => (initialFaqs ? { faqs: initialFaqs } : undefined),\n [initialFaqs],\n )\n const { data, isLoading, error } = useSelfFetch<FaqsResponse>(url, { initialData })\n\n const faqs = data?.faqs ?? []\n // Grouped before the early returns so the hook order stays stable.\n const groups = useMemo(() => (faqs.length > 0 ? groupFaqsBySection(faqs) : []), [faqs])\n\n // `undefined` → default <h2> title; `null` → the host page owns the <h1>, so\n // no title renders here. `heading === null` also makes the category headings\n // <h2> (directly under the page <h1>); otherwise they nest as <h3>.\n const headingNode =\n heading === undefined ? <h2 className={SECTION_HEADING_CLASS}>{DEFAULT_HEADING_TEXT}</h2> : heading\n\n // Degrade silently — never show an error banner or an empty section shell\n // where FAQs would be (host pages and the standalone surface both rely on it).\n if (error) return null\n if (!isLoading && faqs.length === 0) return null\n if (isLoading && faqs.length === 0) {\n return (\n <div className={className}>\n <FaqSkeleton />\n </div>\n )\n }\n\n const schema = emitJsonLd ? buildFaqJsonLdFromFaqs(faqs, jsonLd) : null\n\n return (\n <>\n <section className={className ?? 'space-y-10'}>\n {headingNode}\n <GroupedFaqList groups={groups} categoryHeadingAs={heading === null ? 'h2' : 'h3'} />\n </section>\n {schema && (\n <script\n type=\"application/ld+json\"\n // eslint-disable-next-line react/no-danger\n // serializeJsonLd, NOT raw JSON.stringify — FAQ answers are\n // admin-entered; an embedded \"</script>\" must not break the tag.\n dangerouslySetInnerHTML={{ __html: serializeJsonLd(schema) }}\n />\n )}\n </>\n )\n}\n","\"use client\"\n\nimport React, { useRef, useState, useEffect, useCallback } from 'react'\nimport { ChevronButton } from './ui/chevron-button'\nimport { cn } from \"../utils/cn\"\nimport { faqItemAnchor } from \"../utils/faq-anchor\"\n\nexport interface FaqItem {\n id: number | string\n question: string\n answer: string\n}\n\ninterface FaqAccordionProps {\n items: FaqItem[]\n defaultOpenIds?: (number | string)[]\n}\n\n// Utility to measure scrollHeight outside render cycle\nconst useMeasuredHeight = (isOpen: boolean) => {\n const ref = useRef<HTMLDivElement | null>(null)\n const [maxHeight, setMaxHeight] = useState<string>('0px')\n\n const measure = useCallback(() => {\n if (ref.current) {\n const height = ref.current.scrollHeight\n setMaxHeight(`${height}px`)\n }\n }, [])\n\n // Update height only when section is open\n useEffect(() => {\n if (isOpen) {\n measure()\n } else {\n setMaxHeight('0px')\n }\n }, [isOpen, measure])\n\n return { ref, maxHeight }\n}\n\nexport function FaqAccordion({ items, defaultOpenIds = [] }: FaqAccordionProps) {\n const [openSet, setOpenSet] = useState<Set<string | number>>(new Set(defaultOpenIds))\n\n const toggle = (id: string | number) => {\n setOpenSet(prev => {\n const next = new Set(prev)\n if (next.has(id)) next.delete(id)\n else next.add(id)\n return next\n })\n }\n\n return (\n <div className=\"rounded-3xl border border-ods-border divide-y divide-ods-border bg-ods-card overflow-hidden\">\n {items.map(item => {\n const isOpen = openSet.has(item.id)\n const { ref, maxHeight } = useMeasuredHeight(isOpen)\n\n return (\n <div\n key={item.id}\n // Per-row anchor — chat citation chips (`/faqs#faq-item-<id>`) land\n // here via native browser hash scroll AND via `FaqSection`'s tween\n // dispatch. `scroll-mt-24` keeps the row header below the 96px\n // sticky nav offset (matches `<section>`'s scroll-margin for\n // category anchors).\n id={faqItemAnchor(item.id)}\n className={cn('group scroll-mt-24 transition-colors hover:bg-[#1E1E1E]', isOpen ? 'bg-ods-bg' : 'bg-transparent')}\n >\n {/* Header */}\n <div\n role=\"button\"\n tabIndex={0}\n onClick={() => toggle(item.id)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n toggle(item.id);\n }\n }}\n aria-expanded={isOpen}\n className=\"flex w-full items-center justify-between px-6 md:px-8 py-6 text-left focus:outline-none transition-colors cursor-pointer\"\n >\n <div className=\"min-w-0 pr-4\">\n <h3>\n {item.question}\n </h3>\n </div>\n <div className=\"flex-shrink-0\">\n <ChevronButton\n aria-label={isOpen ? 'Collapse question' : 'Expand question'}\n size=\"md\"\n isExpanded={isOpen}\n backgroundColor=\"transparent\"\n borderColor=\"#3A3A3A\"\n />\n </div>\n </div>\n {/* Content wrapper with max-height animation */}\n <div\n style={{ maxHeight, transition: 'max-height 0.35s ease-in-out, opacity 0.35s ease-in-out', opacity: isOpen ? 1 : 0 }}\n className=\"overflow-hidden group-hover:bg-[#1E1E1E]/30\"\n >\n {/* break-words: FAQ answers render as plain text, so a long URL or\n token has no wrap opportunity — and the parent is overflow-hidden,\n which would CLIP it past the viewport on mobile. Mirrors the\n markdown-renderer overflow-wrap fix. */}\n <div ref={ref} className=\"px-6 md:px-8 pb-6 text-ods-text-primary text-h4 break-words\">\n {item.answer}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )\n} ","/**\n * Pure FAQ JSON-LD builder. No React, no client-only deps — safe to import from\n * Server Components via the `./components/faq` subpath export. (Do NOT import\n * through the root `./components` barrel — that barrel is `\"use client\"` and\n * dragging it into a Server Component would force the client graph into the\n * server.)\n *\n * The hub used to harcode `name`/`description` here for OpenMSP; in the lib we\n * accept overrides so every embedder can supply its own platform branding.\n */\nimport type { Faq } from '../../types/faq'\n\nexport interface FaqSchemaOptions {\n name?: string\n description?: string\n url?: string\n}\n\nconst DEFAULT_NAME = 'Frequently Asked Questions'\nconst DEFAULT_DESCRIPTION =\n 'Answers to common questions.'\n\nexport function baseFaqSchema(opts: FaqSchemaOptions = {}) {\n return {\n '@context': 'https://schema.org',\n '@type': 'FAQPage',\n name: opts.name ?? DEFAULT_NAME,\n description: opts.description ?? DEFAULT_DESCRIPTION,\n ...(opts.url ? { url: opts.url } : {}),\n } as const\n}\n\nexport function buildFaqJsonLdFromFaqs(faqs: Faq[], opts: FaqSchemaOptions = {}) {\n return {\n ...baseFaqSchema(opts),\n mainEntity: faqs.map((faq) => ({\n '@type': 'Question',\n name: faq.question,\n acceptedAnswer: {\n '@type': 'Answer',\n text: faq.answer,\n },\n })),\n } as const\n}\n","'use client';\n\n/**\n * FaqDocumentPage — the full `/faqs` page with chrome, so embedders drop in\n * ONE component instead of hand-assembling `PageShell` + `PageLayout` around the\n * bare `<FaqSection>`. Mirrors `LegalDocumentPage` / `DevSectionPage`: the\n * page-level layout lives in the lib, the host passes only config + a back button.\n *\n * `<FaqSection heading={null}>` lets `PageLayout`'s `TitleBlock` own the heading +\n * back button; it self-fetches `${apiBaseUrl}/api/faqs` via the authed\n * `useSelfFetch`, and renders nothing on a fetch error or zero FAQs.\n */\n\nimport { PageShell, PageLayout } from '../ui';\nimport { useRouter } from '../../embed-shims/next-navigation';\nimport { FaqSection } from './faq-section';\n\nexport interface FaqDocumentPageProps {\n /** Page title (PageLayout TitleBlock). Default \"FAQs\". */\n title?: string;\n /** Subtitle under the title. */\n subtitle?: string;\n /** Back-button config — same pattern as `DevSectionPage` / `LegalDocumentPage`.\n * Pass `false` to hide. Default `{ label: 'Back to home', href: '/' }`. */\n backButton?: { label?: string; href?: string } | false;\n /** Base URL `FaqSection` appends `/api/faqs` to (reverse-proxy embedders). */\n apiBaseUrl?: string;\n /** Optional entity scoping forwarded to `FaqSection`. */\n entityType?: string;\n entityId?: number | string;\n /** Minimum FAQ count before the section renders (forwarded to `FaqSection`). */\n minResults?: number;\n}\n\nexport function FaqDocumentPage({\n title = 'FAQs',\n subtitle,\n backButton,\n apiBaseUrl,\n entityType,\n entityId,\n minResults,\n}: FaqDocumentPageProps) {\n const router = useRouter();\n\n // Back-button config — mirrors LegalDocumentPage/DevSectionPage. Hide entirely\n // when the caller passes `false` (embed-mode where the host owns nav chrome).\n const backCfg =\n backButton === false\n ? undefined\n : {\n label: backButton?.label ?? 'Back to home',\n onClick: () => router.push(backButton?.href ?? '/'),\n };\n\n return (\n <PageShell>\n <PageLayout title={title} subtitle={subtitle} backButton={backCfg}>\n <FaqSection\n heading={null}\n apiBaseUrl={apiBaseUrl}\n entityType={entityType}\n entityId={entityId}\n minResults={minResults}\n />\n </PageLayout>\n </PageShell>\n );\n}\n"]}
|