@flamingo-stack/openframe-frontend-core 0.0.626 → 0.0.627-2168.6177.1
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-63F2UQDW.cjs → chunk-2RWADKBR.cjs} +18 -18
- package/dist/{chunk-63F2UQDW.cjs.map → chunk-2RWADKBR.cjs.map} +1 -1
- package/dist/{chunk-X3LC6R37.js → chunk-32P6KUZP.js} +2 -2
- package/dist/{chunk-RVK3CL5S.js → chunk-3D45OAWL.js} +12 -12
- package/dist/{chunk-EHAYNUOL.cjs → chunk-4E7XCEV3.cjs} +77 -2
- package/dist/chunk-4E7XCEV3.cjs.map +1 -0
- package/dist/{chunk-L54LFB6V.cjs → chunk-5P3V6VFN.cjs} +15 -15
- package/dist/{chunk-L54LFB6V.cjs.map → chunk-5P3V6VFN.cjs.map} +1 -1
- package/dist/{chunk-2CCIF5QV.js → chunk-5YT6NGPV.js} +10 -8
- package/dist/{chunk-2CCIF5QV.js.map → chunk-5YT6NGPV.js.map} +1 -1
- package/dist/{chunk-U7TTQV4N.cjs → chunk-6I3KNDBF.cjs} +3 -3
- package/dist/{chunk-U7TTQV4N.cjs.map → chunk-6I3KNDBF.cjs.map} +1 -1
- package/dist/{chunk-S6WBBSII.js → chunk-76HB456V.js} +5 -5
- package/dist/{chunk-VOBOO7EF.cjs → chunk-76SF25HQ.cjs} +83 -83
- package/dist/{chunk-VOBOO7EF.cjs.map → chunk-76SF25HQ.cjs.map} +1 -1
- package/dist/{chunk-DLZFFGQ7.js → chunk-AGYKSJSE.js} +4 -4
- package/dist/{chunk-34GEH24Y.cjs → chunk-AONK75QT.cjs} +22 -20
- package/dist/chunk-AONK75QT.cjs.map +1 -0
- package/dist/{chunk-IJYP2DMW.js → chunk-B2DCZVUN.js} +8 -354
- package/dist/chunk-B2DCZVUN.js.map +1 -0
- package/dist/{chunk-QR2FJE2C.js → chunk-C6TNAYHO.js} +12 -12
- package/dist/{chunk-YQCA4ZEJ.js → chunk-CMUNJZWN.js} +2 -2
- package/dist/{chunk-F4TAUCHQ.js → chunk-CSP4GOQ2.js} +3 -3
- package/dist/{chunk-3LKJ6JWZ.cjs → chunk-DCBDNYYW.cjs} +34 -34
- package/dist/{chunk-3LKJ6JWZ.cjs.map → chunk-DCBDNYYW.cjs.map} +1 -1
- package/dist/{chunk-Z42VU7HF.cjs → chunk-DGYDHQWL.cjs} +49 -47
- package/dist/chunk-DGYDHQWL.cjs.map +1 -0
- package/dist/{chunk-QPQCQWAW.cjs → chunk-EAPER4P2.cjs} +28 -26
- package/dist/chunk-EAPER4P2.cjs.map +1 -0
- package/dist/{chunk-HTIDXF43.cjs → chunk-EH5BWSOS.cjs} +7 -7
- package/dist/{chunk-HTIDXF43.cjs.map → chunk-EH5BWSOS.cjs.map} +1 -1
- package/dist/{chunk-H7KQM3VI.js → chunk-FNT5JQDQ.js} +8 -8
- package/dist/{chunk-KK7YEVTQ.js → chunk-FRDSHK7F.js} +4 -4
- package/dist/{chunk-Q5XGBLT5.cjs → chunk-GESNG4HT.cjs} +509 -87
- package/dist/chunk-GESNG4HT.cjs.map +1 -0
- package/dist/{chunk-IZG3VYDV.js → chunk-GKCQIJE7.js} +4 -4
- package/dist/{chunk-E7YNDGRN.cjs → chunk-GNASINHO.cjs} +105 -105
- package/dist/{chunk-E7YNDGRN.cjs.map → chunk-GNASINHO.cjs.map} +1 -1
- package/dist/{chunk-5LIDR7HL.js → chunk-JRYS4VMV.js} +4 -79
- package/dist/{chunk-5LIDR7HL.js.map → chunk-JRYS4VMV.js.map} +1 -1
- package/dist/{chunk-QJ6BCSFQ.cjs → chunk-LAYQ3VUW.cjs} +5 -5
- package/dist/{chunk-QJ6BCSFQ.cjs.map → chunk-LAYQ3VUW.cjs.map} +1 -1
- package/dist/{chunk-ESSHEVZQ.cjs → chunk-MFHGLBCL.cjs} +38 -38
- package/dist/chunk-MFHGLBCL.cjs.map +1 -0
- package/dist/{chunk-S43SLJIN.cjs → chunk-MVPPH4EZ.cjs} +25 -25
- package/dist/{chunk-S43SLJIN.cjs.map → chunk-MVPPH4EZ.cjs.map} +1 -1
- package/dist/{chunk-WEDSYUSR.js → chunk-ONTFCKVK.js} +6 -6
- package/dist/{chunk-3POP5WWC.cjs → chunk-P32VEWOW.cjs} +6 -6
- package/dist/{chunk-3POP5WWC.cjs.map → chunk-P32VEWOW.cjs.map} +1 -1
- package/dist/{chunk-3IXDZI3R.cjs → chunk-P7UT2YSC.cjs} +3 -3
- package/dist/{chunk-3IXDZI3R.cjs.map → chunk-P7UT2YSC.cjs.map} +1 -1
- package/dist/{chunk-RGMUA4XB.js → chunk-PDFHLSPP.js} +7 -7
- package/dist/{chunk-MZWSJPDZ.js → chunk-QBX4BI5E.js} +16 -28
- package/dist/{chunk-MZWSJPDZ.js.map → chunk-QBX4BI5E.js.map} +1 -1
- package/dist/{chunk-JJUV7Z4L.cjs → chunk-QIVX7F3N.cjs} +27 -27
- package/dist/{chunk-JJUV7Z4L.cjs.map → chunk-QIVX7F3N.cjs.map} +1 -1
- package/dist/{chunk-P7KIFYZI.js → chunk-QPHOTZDX.js} +10 -8
- package/dist/{chunk-P7KIFYZI.js.map → chunk-QPHOTZDX.js.map} +1 -1
- package/dist/{chunk-2MMEPNSX.cjs → chunk-RAPPN6MN.cjs} +3 -3
- package/dist/{chunk-2MMEPNSX.cjs.map → chunk-RAPPN6MN.cjs.map} +1 -1
- package/dist/{chunk-BVCWBA2U.js → chunk-RD627HGV.js} +817 -395
- package/dist/chunk-RD627HGV.js.map +1 -0
- package/dist/{chunk-NLVBO3IR.js → chunk-RFM6NMF7.js} +10 -8
- package/dist/{chunk-NLVBO3IR.js.map → chunk-RFM6NMF7.js.map} +1 -1
- package/dist/{chunk-NZJNXGU2.cjs → chunk-S3WX4GNN.cjs} +280 -292
- package/dist/chunk-S3WX4GNN.cjs.map +1 -0
- package/dist/{chunk-RQQAPCOU.js → chunk-STRI4K3F.js} +3 -3
- package/dist/{chunk-LJ7KMQRM.cjs → chunk-T3HJAG5Y.cjs} +42 -42
- package/dist/{chunk-LJ7KMQRM.cjs.map → chunk-T3HJAG5Y.cjs.map} +1 -1
- package/dist/{chunk-DZ7CEES3.js → chunk-TIPGW4JM.js} +5 -5
- package/dist/{chunk-DZ7CEES3.js.map → chunk-TIPGW4JM.js.map} +1 -1
- package/dist/{chunk-FKBM6U43.js → chunk-USIRWQJ3.js} +76 -1
- package/dist/{chunk-FKBM6U43.js.map → chunk-USIRWQJ3.js.map} +1 -1
- package/dist/{chunk-CCWI3622.cjs → chunk-VOZZQ6HQ.cjs} +4 -4
- package/dist/{chunk-CCWI3622.cjs.map → chunk-VOZZQ6HQ.cjs.map} +1 -1
- package/dist/{chunk-MSVEZB5D.cjs → chunk-W54VLUS5.cjs} +279 -625
- package/dist/chunk-W54VLUS5.cjs.map +1 -0
- package/dist/{chunk-F2KBCLUG.js → chunk-X5NN4NJM.js} +2 -2
- package/dist/{chunk-CPO5KPW6.cjs → chunk-XDZIHPF2.cjs} +9 -9
- package/dist/{chunk-CPO5KPW6.cjs.map → chunk-XDZIHPF2.cjs.map} +1 -1
- package/dist/{chunk-ZIEYC6ZB.js → chunk-YDZ5S3Z2.js} +4 -4
- package/dist/{chunk-YXWGSDK4.cjs → chunk-ZI27ALYX.cjs} +5 -80
- package/dist/chunk-ZI27ALYX.cjs.map +1 -0
- package/dist/{chunk-BVQEU5JB.js → chunk-ZOMGXH7C.js} +2 -2
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +8 -8
- package/dist/components/chat/entity-cards/ai-prompt-card.d.ts +2 -1
- package/dist/components/chat/entity-cards/ai-prompt-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/employee-entry-card.d.ts +3 -3
- package/dist/components/chat/entity-cards/employee-entry-card.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/entity-author-card.d.ts +8 -6
- package/dist/components/chat/entity-cards/entity-author-card.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +5 -5
- package/dist/components/chat/index.js +4 -4
- package/dist/components/contact/index.cjs +9 -9
- package/dist/components/contact/index.js +8 -8
- package/dist/components/docs/index.cjs +12 -12
- package/dist/components/docs/index.js +11 -11
- package/dist/components/embeds/index.cjs +9 -9
- package/dist/components/embeds/index.js +8 -8
- package/dist/components/faq/index.cjs +10 -10
- package/dist/components/faq/index.js +9 -9
- package/dist/components/features/index.cjs +8 -8
- package/dist/components/features/index.js +7 -7
- package/dist/components/help-center-pages/index.cjs +31 -31
- package/dist/components/help-center-pages/index.js +22 -22
- package/dist/components/index.cjs +75 -69
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +30 -24
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +49 -49
- package/dist/components/meeting-scheduler/index.js +9 -9
- package/dist/components/navigation/index.cjs +11 -11
- package/dist/components/navigation/index.js +10 -10
- package/dist/components/onboarding-guides/index.cjs +12 -12
- package/dist/components/onboarding-guides/index.js +11 -11
- package/dist/components/related-content/card-registry.d.ts.map +1 -1
- package/dist/components/related-content/index.cjs +6 -6
- package/dist/components/related-content/index.js +5 -5
- package/dist/components/tickets/index.cjs +13 -13
- package/dist/components/tickets/index.js +12 -12
- package/dist/components/ui/color-preset-select.d.ts +4 -5
- package/dist/components/ui/color-preset-select.d.ts.map +1 -1
- package/dist/components/ui/department-badge.d.ts +21 -0
- package/dist/components/ui/department-badge.d.ts.map +1 -0
- package/dist/components/ui/index.cjs +14 -8
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.d.ts.map +1 -1
- package/dist/components/ui/index.js +13 -7
- package/dist/components/ui/palette-badge.d.ts +18 -0
- package/dist/components/ui/palette-badge.d.ts.map +1 -0
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.js +4 -4
- package/dist/index.cjs +28 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +50 -40
- package/dist/index.js.map +1 -1
- package/dist/types/department.d.ts +4 -0
- package/dist/types/department.d.ts.map +1 -1
- package/dist/utils/color-presets.d.ts +24 -0
- package/dist/utils/color-presets.d.ts.map +1 -0
- package/dist/utils/index.cjs +32 -0
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +30 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/chat/entity-cards/ai-prompt-card.tsx +7 -4
- package/src/components/chat/entity-cards/employee-entry-card.tsx +21 -24
- package/src/components/chat/entity-cards/entity-author-card.tsx +10 -4
- package/src/components/related-content/card-registry.tsx +3 -1
- package/src/components/ui/.department-badge.md +2 -0
- package/src/components/ui/.palette-badge.md +2 -0
- package/src/components/ui/__tests__/department-badge.test.tsx +40 -0
- package/src/components/ui/color-preset-select.tsx +5 -21
- package/src/components/ui/department-badge.tsx +35 -0
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/palette-badge.tsx +35 -0
- package/src/types/department.ts +4 -0
- package/src/utils/.color-presets.md +2 -0
- package/src/utils/color-presets.ts +48 -0
- package/src/utils/index.ts +1 -0
- package/dist/chunk-34GEH24Y.cjs.map +0 -1
- package/dist/chunk-BVCWBA2U.js.map +0 -1
- package/dist/chunk-EHAYNUOL.cjs.map +0 -1
- package/dist/chunk-ESSHEVZQ.cjs.map +0 -1
- package/dist/chunk-IJYP2DMW.js.map +0 -1
- package/dist/chunk-MSVEZB5D.cjs.map +0 -1
- package/dist/chunk-NZJNXGU2.cjs.map +0 -1
- package/dist/chunk-Q5XGBLT5.cjs.map +0 -1
- package/dist/chunk-QPQCQWAW.cjs.map +0 -1
- package/dist/chunk-YXWGSDK4.cjs.map +0 -1
- package/dist/chunk-Z42VU7HF.cjs.map +0 -1
- /package/dist/{chunk-X3LC6R37.js.map → chunk-32P6KUZP.js.map} +0 -0
- /package/dist/{chunk-RVK3CL5S.js.map → chunk-3D45OAWL.js.map} +0 -0
- /package/dist/{chunk-S6WBBSII.js.map → chunk-76HB456V.js.map} +0 -0
- /package/dist/{chunk-DLZFFGQ7.js.map → chunk-AGYKSJSE.js.map} +0 -0
- /package/dist/{chunk-QR2FJE2C.js.map → chunk-C6TNAYHO.js.map} +0 -0
- /package/dist/{chunk-YQCA4ZEJ.js.map → chunk-CMUNJZWN.js.map} +0 -0
- /package/dist/{chunk-F4TAUCHQ.js.map → chunk-CSP4GOQ2.js.map} +0 -0
- /package/dist/{chunk-H7KQM3VI.js.map → chunk-FNT5JQDQ.js.map} +0 -0
- /package/dist/{chunk-KK7YEVTQ.js.map → chunk-FRDSHK7F.js.map} +0 -0
- /package/dist/{chunk-IZG3VYDV.js.map → chunk-GKCQIJE7.js.map} +0 -0
- /package/dist/{chunk-WEDSYUSR.js.map → chunk-ONTFCKVK.js.map} +0 -0
- /package/dist/{chunk-RGMUA4XB.js.map → chunk-PDFHLSPP.js.map} +0 -0
- /package/dist/{chunk-RQQAPCOU.js.map → chunk-STRI4K3F.js.map} +0 -0
- /package/dist/{chunk-F2KBCLUG.js.map → chunk-X5NN4NJM.js.map} +0 -0
- /package/dist/{chunk-ZIEYC6ZB.js.map → chunk-YDZ5S3Z2.js.map} +0 -0
- /package/dist/{chunk-BVQEU5JB.js.map → chunk-ZOMGXH7C.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { formatDateUTC } from '../../../utils/format';
|
|
3
|
+
import { DepartmentBadge } from '../../ui/department-badge';
|
|
3
4
|
import {
|
|
4
5
|
EmployeeEntryBadge,
|
|
5
6
|
EmployeeEntryCard,
|
|
@@ -11,8 +12,8 @@ import {
|
|
|
11
12
|
* related-content hydrated row satisfy it structurally. */
|
|
12
13
|
export interface AiPromptCardData extends EmployeeEntryCardData {
|
|
13
14
|
published_at?: string | null;
|
|
14
|
-
/** The department the prompt is for, surfaced as
|
|
15
|
-
department?: { name?: string | null } | null;
|
|
15
|
+
/** The department the prompt is for, surfaced as THE department badge (the library's filter axis). */
|
|
16
|
+
department?: { name?: string | null; color?: string | null } | null;
|
|
16
17
|
/** How many steps the prompt has. A chain (more than one) is badged. */
|
|
17
18
|
step_count?: number | null;
|
|
18
19
|
}
|
|
@@ -37,7 +38,7 @@ export interface AiPromptCardProps {
|
|
|
37
38
|
* related-content rail (with `anchorProps`), so the card cannot drift between them.
|
|
38
39
|
*/
|
|
39
40
|
export function AiPromptCard({ entry, placeholderUrl, actions, anchorProps, className }: AiPromptCardProps) {
|
|
40
|
-
const
|
|
41
|
+
const departmentName = entry.department?.name?.trim();
|
|
41
42
|
const steps = typeof entry.step_count === 'number' ? entry.step_count : 0;
|
|
42
43
|
return (
|
|
43
44
|
<EmployeeEntryCard
|
|
@@ -45,7 +46,9 @@ export function AiPromptCard({ entry, placeholderUrl, actions, anchorProps, clas
|
|
|
45
46
|
dateLabel={entry.published_at ? formatDateUTC(entry.published_at, { fallback: '' }) || null : null}
|
|
46
47
|
extraBadges={
|
|
47
48
|
<>
|
|
48
|
-
{
|
|
49
|
+
{departmentName ? (
|
|
50
|
+
<DepartmentBadge department={{ name: departmentName, color: entry.department?.color ?? null }} />
|
|
51
|
+
) : null}
|
|
49
52
|
{steps > 1 ? <EmployeeEntryBadge>{`${steps} steps`}</EmployeeEntryBadge> : null}
|
|
50
53
|
</>
|
|
51
54
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import Image from '../../../embed-shims/next-image';
|
|
3
3
|
import { getProxiedImageUrl } from '../../../utils/image-proxy-stub';
|
|
4
|
+
import { StatusBadge, type StatusBadgeProps } from '../../ui/status-badge';
|
|
4
5
|
import { AdminContentCard } from './admin-content-card';
|
|
5
6
|
|
|
6
7
|
/** The fields every people-hub employee entry shares. Entity-specific bindings
|
|
@@ -35,26 +36,23 @@ export interface EmployeeEntryCardProps {
|
|
|
35
36
|
className?: string;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
/** Entry lifecycle → the standard badge colour scheme (the same ODS pairs every status badge uses). */
|
|
40
|
+
const STATUS_BADGE_SCHEME: Record<string, NonNullable<StatusBadgeProps['colorScheme']>> = {
|
|
41
|
+
published: 'success',
|
|
42
|
+
draft: 'warning',
|
|
43
|
+
archived: 'default',
|
|
42
44
|
// Design-doc lifecycle (product-hub) — same ODS pairs, no new palette.
|
|
43
|
-
in_review: '
|
|
44
|
-
approved: '
|
|
45
|
-
building: '
|
|
46
|
-
shipped: '
|
|
47
|
-
abandoned: '
|
|
45
|
+
in_review: 'warning',
|
|
46
|
+
approved: 'success',
|
|
47
|
+
building: 'success',
|
|
48
|
+
shipped: 'success',
|
|
49
|
+
abandoned: 'default',
|
|
48
50
|
};
|
|
49
51
|
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
export function EmployeeEntryBadge({ children }: { children:
|
|
53
|
-
return
|
|
54
|
-
<span className="rounded border border-ods-border bg-ods-card px-2 py-1 text-xs font-medium text-ods-text-secondary">
|
|
55
|
-
{children}
|
|
56
|
-
</span>
|
|
57
|
-
);
|
|
52
|
+
/** An entity's own badge (discipline, level, step count): the standard `StatusBadge`
|
|
53
|
+
* stamp, so it sits at exactly the size and height of the status badge beside it. */
|
|
54
|
+
export function EmployeeEntryBadge({ children }: { children: string }) {
|
|
55
|
+
return <StatusBadge text={children} colorScheme="default" variant="button" singleLine />;
|
|
58
56
|
}
|
|
59
57
|
|
|
60
58
|
/**
|
|
@@ -86,13 +84,12 @@ export function EmployeeEntryCard({
|
|
|
86
84
|
entry.status || extraBadges ? (
|
|
87
85
|
<>
|
|
88
86
|
{entry.status ? (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
</span>
|
|
87
|
+
<StatusBadge
|
|
88
|
+
text={entry.status}
|
|
89
|
+
colorScheme={STATUS_BADGE_SCHEME[entry.status] ?? 'default'}
|
|
90
|
+
variant="button"
|
|
91
|
+
singleLine
|
|
92
|
+
/>
|
|
96
93
|
) : null}
|
|
97
94
|
{extraBadges}
|
|
98
95
|
</>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type React from 'react';
|
|
1
2
|
import Link from '../../../embed-shims/next-link';
|
|
2
3
|
import type { EntityAuthor } from '../../../types/entity-author';
|
|
3
4
|
import { formatDate, nameInitials } from '../../../utils/format';
|
|
@@ -60,7 +61,7 @@ export interface EntityAuthorCardProps {
|
|
|
60
61
|
* webinar host, customer-interview customer). The grid auto-sizes via
|
|
61
62
|
* `grid-cols-N`.
|
|
62
63
|
*/
|
|
63
|
-
extraCells?: Array<{ value:
|
|
64
|
+
extraCells?: Array<{ value: React.ReactNode; label: string; uppercase?: boolean }>;
|
|
64
65
|
/** When true, render the author cell even when `author?.full_name` is
|
|
65
66
|
* missing — using the `EMPTY_AUTHOR_PLACEHOLDER` shape above. Used by
|
|
66
67
|
* catalog grids that must keep a fixed shape so skeleton alignment
|
|
@@ -71,7 +72,8 @@ export interface EntityAuthorCardProps {
|
|
|
71
72
|
|
|
72
73
|
/**
|
|
73
74
|
* Single value cell — top: large `text-h4` value (uppercase), bottom: small
|
|
74
|
-
* `DM_Sans` 14px secondary label.
|
|
75
|
+
* `DM_Sans` 14px secondary label. A non-text value (a `DepartmentBadge`) renders
|
|
76
|
+
* as given in the value slot.
|
|
75
77
|
*/
|
|
76
78
|
export function EntityMetadataValueCell({
|
|
77
79
|
value,
|
|
@@ -79,7 +81,7 @@ export function EntityMetadataValueCell({
|
|
|
79
81
|
className,
|
|
80
82
|
uppercase = true,
|
|
81
83
|
}: {
|
|
82
|
-
value:
|
|
84
|
+
value: React.ReactNode;
|
|
83
85
|
label: string;
|
|
84
86
|
className?: string;
|
|
85
87
|
uppercase?: boolean;
|
|
@@ -87,7 +89,11 @@ export function EntityMetadataValueCell({
|
|
|
87
89
|
return (
|
|
88
90
|
<div className={`flex flex-col gap-3 bg-ods-card p-4 ${className ?? ''}`}>
|
|
89
91
|
<div className="flex flex-col gap-0">
|
|
90
|
-
|
|
92
|
+
{typeof value === 'string' ? (
|
|
93
|
+
<p className="text-ods-text-primary text-h4">{uppercase ? value.toLocaleUpperCase() : value}</p>
|
|
94
|
+
) : (
|
|
95
|
+
<div className="flex min-h-6 items-center">{value}</div>
|
|
96
|
+
)}
|
|
91
97
|
<p className="text-ods-text-secondary text-h6">{label}</p>
|
|
92
98
|
</div>
|
|
93
99
|
</div>
|
|
@@ -527,7 +527,9 @@ function decodeEmployeeEntryRow(row: unknown): WhatIShippedCardData & HowIWorkCa
|
|
|
527
527
|
session_date: strOrNull(record, 'session_date'),
|
|
528
528
|
discipline: strOrNull(record, 'discipline'),
|
|
529
529
|
published_at: strOrNull(record, 'published_at'),
|
|
530
|
-
department: record.department
|
|
530
|
+
department: record.department
|
|
531
|
+
? { name: strOrNull(department, 'name'), color: strOrNull(department, 'color') }
|
|
532
|
+
: null,
|
|
531
533
|
step_count: typeof stepCount === 'number' ? stepCount : null,
|
|
532
534
|
};
|
|
533
535
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { COLOR_PRESETS, pickPresetColor } from '../../../utils/color-presets';
|
|
4
|
+
import { DepartmentBadge } from '../department-badge';
|
|
5
|
+
import { PaletteBadge } from '../palette-badge';
|
|
6
|
+
|
|
7
|
+
describe('PaletteBadge', () => {
|
|
8
|
+
it('fills the badge with the palette colour a key names', () => {
|
|
9
|
+
render(<PaletteBadge text="Teal" color="teal" />);
|
|
10
|
+
expect(screen.getByText('Teal')).toHaveStyle({ backgroundColor: 'rgb(77, 182, 172)' });
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('renders neutral for an unknown colour', () => {
|
|
14
|
+
render(<PaletteBadge text="Other" color="not-a-colour" />);
|
|
15
|
+
expect(screen.getByText('Other')).not.toHaveAttribute('style');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('DepartmentBadge', () => {
|
|
20
|
+
it("uses the department's stored palette colour, and the empty label without a department", () => {
|
|
21
|
+
const { rerender } = render(<DepartmentBadge department={{ name: 'Marketing', color: 'sky' }} />);
|
|
22
|
+
expect(screen.getByText('Marketing')).toHaveStyle({ backgroundColor: 'rgb(79, 195, 247)' });
|
|
23
|
+
rerender(<DepartmentBadge department={null} emptyLabel="Unassigned" />);
|
|
24
|
+
expect(screen.getByText('Unassigned')).not.toHaveStyle({ backgroundColor: 'rgb(79, 195, 247)' });
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('pickPresetColor', () => {
|
|
29
|
+
it('picks a palette key that is not taken, and never neutral', () => {
|
|
30
|
+
const keys = COLOR_PRESETS.map(preset => preset.key);
|
|
31
|
+
const taken = keys.filter(key => key !== 'teal' && key !== 'neutral');
|
|
32
|
+
for (let run = 0; run < 10; run++) expect(pickPresetColor({ avoid: taken })).toBe('teal');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('repeats a colour only once every colour is taken', () => {
|
|
36
|
+
const everything = COLOR_PRESETS.map(preset => preset.key);
|
|
37
|
+
expect(everything).toContain(pickPresetColor({ avoid: everything }));
|
|
38
|
+
expect(pickPresetColor({ avoid: everything })).not.toBe('neutral');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import { HexColorPicker } from 'react-colorful';
|
|
5
5
|
import { cn } from '../../utils/cn';
|
|
6
|
+
import { COLOR_PRESETS, type ColorPreset } from '../../utils/color-presets';
|
|
6
7
|
import { HEX_PATTERN, hexToRgb, hslToRgb, rgbToHex, rgbToHsl } from '../../utils/ods-color-utils';
|
|
7
8
|
import { Chevron02DownIcon } from '../icons-v2-generated/arrows/chevron-02-down-icon';
|
|
8
9
|
import { Popover, PopoverContent, PopoverTrigger } from '../popover';
|
|
@@ -11,27 +12,10 @@ import { ColorSwatch } from './color-swatch';
|
|
|
11
12
|
import { Input } from './input';
|
|
12
13
|
import { InputTrigger } from './input-trigger';
|
|
13
14
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Ticket-status palette.
|
|
21
|
-
export const TICKET_STATUS_COLOR_PRESETS: readonly ColorPreset[] = [
|
|
22
|
-
{ key: 'green', label: 'Green', color: '#5ea62e' },
|
|
23
|
-
{ key: 'lime', label: 'Lime', color: '#8bc34a' },
|
|
24
|
-
{ key: 'teal', label: 'Teal', color: '#4db6ac' },
|
|
25
|
-
{ key: 'sky', label: 'Sky', color: '#4fc3f7' },
|
|
26
|
-
{ key: 'periwinkle', label: 'Periwinkle', color: '#7e9cd8' },
|
|
27
|
-
{ key: 'lavender', label: 'Lavender', color: '#b39ddb' },
|
|
28
|
-
{ key: 'yellow', label: 'Yellow', color: '#e1b32f' },
|
|
29
|
-
{ key: 'sand', label: 'Sand', color: '#f0c674' },
|
|
30
|
-
{ key: 'peach', label: 'Peach', color: '#f39c7a' },
|
|
31
|
-
{ key: 'red', label: 'Red', color: '#f36666' },
|
|
32
|
-
{ key: 'pink', label: 'Pink', color: '#e988a8' },
|
|
33
|
-
{ key: 'neutral', label: 'Neutral', color: '#b0b0b0' },
|
|
34
|
-
];
|
|
15
|
+
export type { ColorPreset } from '../../utils/color-presets';
|
|
16
|
+
export { COLOR_PRESETS } from '../../utils/color-presets';
|
|
17
|
+
/** The palette ticket statuses pick from: the shared `COLOR_PRESETS`. */
|
|
18
|
+
export const TICKET_STATUS_COLOR_PRESETS = COLOR_PRESETS;
|
|
35
19
|
|
|
36
20
|
export const CUSTOM_PRESET_KEY = 'custom';
|
|
37
21
|
export const DEFAULT_CUSTOM_STATUS_COLOR = '#888888';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { DepartmentRef } from '../../types/department';
|
|
4
|
+
import { PaletteBadge, type PaletteBadgeProps } from './palette-badge';
|
|
5
|
+
|
|
6
|
+
export interface DepartmentBadgeProps {
|
|
7
|
+
/** A department reference; its stored `color` (a palette key) fills the badge. */
|
|
8
|
+
department: { name: DepartmentRef['name']; color?: DepartmentRef['color'] } | null | undefined;
|
|
9
|
+
/** Text when there is no department. */
|
|
10
|
+
emptyLabel?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
variant?: PaletteBadgeProps['variant'];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* THE department badge: the shared `PaletteBadge` in the department's own colour.
|
|
17
|
+
* The colour is data, `departments.color`, a `COLOR_PRESETS` key picked at random
|
|
18
|
+
* (`pickPresetColor`) when the department is created, so no department or colour
|
|
19
|
+
* is listed in code.
|
|
20
|
+
*/
|
|
21
|
+
export function DepartmentBadge({
|
|
22
|
+
department,
|
|
23
|
+
emptyLabel = 'No department',
|
|
24
|
+
className,
|
|
25
|
+
variant,
|
|
26
|
+
}: DepartmentBadgeProps) {
|
|
27
|
+
return (
|
|
28
|
+
<PaletteBadge
|
|
29
|
+
text={department?.name || emptyLabel}
|
|
30
|
+
color={department?.name ? department.color : null}
|
|
31
|
+
className={className}
|
|
32
|
+
variant={variant}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -67,6 +67,8 @@ export * from './release-changelog-section';
|
|
|
67
67
|
export * from './stacked-rows-panel';
|
|
68
68
|
export * from './slack-channel-chip';
|
|
69
69
|
export * from './status-badge';
|
|
70
|
+
export * from './palette-badge';
|
|
71
|
+
export * from './department-badge';
|
|
70
72
|
export * from './status-indicator';
|
|
71
73
|
export * from './toaster';
|
|
72
74
|
// TODO: Add other UI components as they are moved to ui-kit
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { colorPreset } from '../../utils/color-presets';
|
|
4
|
+
import { HEX_PATTERN, getReadableTextColor } from '../../utils/ods-color-utils';
|
|
5
|
+
import { StatusBadge, type StatusBadgeProps } from './status-badge';
|
|
6
|
+
|
|
7
|
+
export interface PaletteBadgeProps {
|
|
8
|
+
text: string;
|
|
9
|
+
/** A `COLOR_PRESETS` key (or a `#rrggbb` custom colour). Unknown or missing renders neutral. */
|
|
10
|
+
color?: string | null;
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Defaults to the dense `button` stamp, the size every inline badge beside it uses. */
|
|
13
|
+
variant?: StatusBadgeProps['variant'];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* THE badge for anything that carries its own colour from the shared palette
|
|
18
|
+
* (`COLOR_PRESETS`): a department, a custom ticket status, any row whose colour
|
|
19
|
+
* is data. It is the standard `StatusBadge` stamp filled with the colour, with the
|
|
20
|
+
* label colour picked for contrast, so it matches the size, weight, casing and
|
|
21
|
+
* height of every other badge.
|
|
22
|
+
*/
|
|
23
|
+
export function PaletteBadge({ text, color, className, variant = 'button' }: PaletteBadgeProps) {
|
|
24
|
+
const fill = colorPreset(color)?.color ?? (color && HEX_PATTERN.test(color) ? color : null);
|
|
25
|
+
return (
|
|
26
|
+
<StatusBadge
|
|
27
|
+
text={text}
|
|
28
|
+
colorScheme="default"
|
|
29
|
+
variant={variant}
|
|
30
|
+
singleLine
|
|
31
|
+
className={className}
|
|
32
|
+
style={fill ? { backgroundColor: fill, color: getReadableTextColor(fill) } : undefined}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
package/src/types/department.ts
CHANGED
|
@@ -20,11 +20,14 @@ export interface Department {
|
|
|
20
20
|
parent_department_id?: string | null;
|
|
21
21
|
display_order: number;
|
|
22
22
|
is_active: boolean;
|
|
23
|
+
/** The department's badge colour: a `COLOR_PRESETS` key picked at random (`pickPresetColor`) when the row is created. */
|
|
24
|
+
color: string | null;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
/** The embedded shape a reader gets through the `department:departments(…)` PostgREST embed. */
|
|
26
28
|
export type DepartmentRef = Pick<Department, 'id' | 'name' | 'slug'> & {
|
|
27
29
|
display_order?: number;
|
|
30
|
+
color?: string | null;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
/** `GET /api/admin/departments?counts=…` row — a department plus how many profiles carry it. */
|
|
@@ -32,6 +35,7 @@ export interface DepartmentSummary {
|
|
|
32
35
|
id: string;
|
|
33
36
|
name: string;
|
|
34
37
|
slug: string;
|
|
38
|
+
color?: string | null;
|
|
35
39
|
count: number;
|
|
36
40
|
}
|
|
37
41
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE colour palette for data that carries its own colour: ticket statuses picked
|
|
3
|
+
* in `ColorPresetSelect`, a department's badge, any future row with an identity
|
|
4
|
+
* colour. One list, so every coloured badge in the product reads from the same
|
|
5
|
+
* design-system swatches.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface ColorPreset {
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
color: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const COLOR_PRESETS: readonly ColorPreset[] = [
|
|
15
|
+
{ key: 'green', label: 'Green', color: '#5ea62e' },
|
|
16
|
+
{ key: 'lime', label: 'Lime', color: '#8bc34a' },
|
|
17
|
+
{ key: 'teal', label: 'Teal', color: '#4db6ac' },
|
|
18
|
+
{ key: 'sky', label: 'Sky', color: '#4fc3f7' },
|
|
19
|
+
{ key: 'periwinkle', label: 'Periwinkle', color: '#7e9cd8' },
|
|
20
|
+
{ key: 'lavender', label: 'Lavender', color: '#b39ddb' },
|
|
21
|
+
{ key: 'yellow', label: 'Yellow', color: '#e1b32f' },
|
|
22
|
+
{ key: 'sand', label: 'Sand', color: '#f0c674' },
|
|
23
|
+
{ key: 'peach', label: 'Peach', color: '#f39c7a' },
|
|
24
|
+
{ key: 'red', label: 'Red', color: '#f36666' },
|
|
25
|
+
{ key: 'pink', label: 'Pink', color: '#e988a8' },
|
|
26
|
+
{ key: 'neutral', label: 'Neutral', color: '#b0b0b0' },
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
/** The preset a key names, or `undefined`. */
|
|
30
|
+
export function colorPreset(key: string | null | undefined): ColorPreset | undefined {
|
|
31
|
+
return key ? COLOR_PRESETS.find(preset => preset.key === key) : undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A random preset key for a new row that needs an identity colour. Prefers a
|
|
36
|
+
* preset nobody in `avoid` uses yet (neutral is never picked: it reads as "no
|
|
37
|
+
* colour"); once every colour is taken, any colour may repeat.
|
|
38
|
+
*/
|
|
39
|
+
export function pickPresetColor({
|
|
40
|
+
avoid = [],
|
|
41
|
+
random = Math.random,
|
|
42
|
+
}: { avoid?: ReadonlyArray<string | null | undefined>; random?: () => number } = {}): string {
|
|
43
|
+
const colours = COLOR_PRESETS.filter(preset => preset.key !== 'neutral');
|
|
44
|
+
const used = new Set(avoid);
|
|
45
|
+
const free = colours.filter(preset => !used.has(preset.key));
|
|
46
|
+
const pool = free.length > 0 ? free : colours;
|
|
47
|
+
return pool[Math.floor(random() * pool.length) % pool.length].key;
|
|
48
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-34GEH24Y.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":["useState","jsx"],"mappings":"AAAA,6rBAAY;AACZ;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AAC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MAAA;AACT,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AAAA,IAAA;AAEJ,EAAA;AAG8C,EAAA;AAClD;AJ2PoF;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-34GEH24Y.cjs","sourcesContent":[null,"'use client';\n\nimport type React from 'react';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useScrollToHash } from '../../hooks/use-scroll-to-hash';\nimport { useSelfFetch } from '../../hooks/use-self-fetch';\nimport type { Faq } from '../../types/faq';\nimport { cn } from '../../utils/cn';\nimport { serializeJsonLd } from '../../utils/common';\nimport { faqSectionSlug, parseFaqHash, type FaqHashTarget } from '../../utils/faq-anchor';\nimport { navigateSamePageHash, STICKY_HEADER_OFFSET_PX } from '../../utils/same-page-hash-nav';\nimport { buildSuggestionUrl } from '../../utils/suggestion-url';\nimport { FaqAccordion, type FaqItem } from '../faq-accordion';\nimport { SECTION_HEADING_CLASS } from '../layout/page-heading';\nimport { buildFaqJsonLdFromFaqs, type FaqSchemaOptions } from './json-ld';\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(entityType?: string, entityId?: number | string, minResults?: number, apiBaseUrl = ''): 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 // A Map iterates in insertion order, which is exactly the first-seen section\n // order this function promises — so the Map IS the ordering, and no parallel\n // array of names (plus a lookup that has to assert the key back) is needed.\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 }\n group.items.push(item);\n }\n const groups = [...byName.values()];\n if (uncategorized) groups.push(uncategorized);\n return groups;\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 // Latest `navGroups` for the scroll-spy observer below, which re-observes on\n // `slugKey` (the section SET) and must not re-run when the array is merely\n // rebuilt with the same slugs.\n const navGroupsRef = useRef(navGroups);\n useEffect(() => {\n navGroupsRef.current = navGroups;\n });\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 (navGroupsRef.current.length < 2) return undefined;\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 navGroupsRef.current) {\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 }, [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 = hashTarget?.kind === 'item' ? `item:${hashTarget.rawId}` : 'default';\n\n // Unified scroll-to-hash: rAF-polls for the target row (outlasts the SWR self-fetch\n // + Radix accordion expand) and re-fires on `hashchange` — including the synthetic\n // event `navigateSamePageHash` dispatches for a SOFT same-page chat-card nav (a\n // host-router `pushState` fires no `hashchange`). The ready-dep keys off BOTH the\n // loaded `groups` (so a deep-link / refresh scrolls once the self-fetched list\n // mounts) AND `hashTarget` (so a soft nav re-runs the scroll AFTER the re-render\n // that remounts + opens the cited row, landing on its FINAL expanded position\n // instead of racing the uncontrolled accordion's key-remount — the bare-`hashchange`\n // listener alone fires before the remount and lands on the stale closed position).\n const scrollDep =\n `${groups.length}|` +\n (hashTarget?.kind === 'item'\n ? `item:${hashTarget.rawId}`\n : hashTarget?.kind === 'section'\n ? `section:${hashTarget.slug}`\n : 'none');\n useScrollToHash(scrollDep, { headerOffset: STICKY_HEADER_OFFSET_PX });\n\n // A section hash also lights up its category pill; item hashes leave the pills\n // untouched so deep-linking a question never disturbs scroll-spy state.\n //\n // Adjusted while rendering (React's prop-sync pattern) rather than from an\n // effect: the pills below read `activeSlug` in THIS render, so an effect\n // painted the OLD pill lit and then re-rendered to move the highlight. The\n // initial value matches `hashTarget`'s own initial `null`, so a mount is a\n // no-op here exactly as the effect's first run was.\n const [pillSyncedHash, setPillSyncedHash] = useState(hashTarget);\n if (pillSyncedHash !== hashTarget) {\n setPillSyncedHash(hashTarget);\n if (hashTarget?.kind === 'section') setActiveSlug(hashTarget.slug);\n }\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((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 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 transition-colors text-h6',\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 key={key} id={group.slug ?? undefined} className=\"scroll-mt-24 space-y-4\">\n {group.section && <CategoryHeading className={SECTION_HEADING_CLASS}>{group.section}</CategoryHeading>}\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=\"animate-pulse space-y-8\">\n <div className=\"h-12 w-2/3 rounded bg-ods-border md:h-14\" />\n <div className=\"w-full divide-y divide-ods-border overflow-hidden rounded-md border border-ods-border bg-transparent\">\n {Array.from({ length: 8 }).map((_, idx) => (\n <div key={idx} className=\"flex items-center justify-between gap-6 px-6 py-4 md:gap-10\">\n <div className=\"h-6 w-5/6 rounded bg-ods-border\" />\n <div className=\"size-6 rounded 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 // Memoised because the `??` fallback minted a NEW array on every\n // render, which made the memo below re-run every time — i.e. do nothing.\n const faqs = useMemo(() => data?.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 // 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 { useState } from 'react';\nimport { cn } from '../utils/cn';\nimport { faqItemAnchor } from '../utils/faq-anchor';\nimport { Chevron02DownIcon } from './icons-v2-generated/arrows/chevron-02-down-icon';\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\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=\"divide-y divide-ods-border overflow-hidden rounded-md border border-ods-border bg-transparent\">\n {items.map(item => {\n const isOpen = openSet.has(item.id);\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=\"scroll-mt-24 transition-colors hover:bg-ods-bg-hover\"\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 cursor-pointer items-center gap-6 px-6 py-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ods-focus md:gap-10\"\n >\n <h3 className=\"min-w-0 flex-1 break-words\">{item.question}</h3>\n <Chevron02DownIcon\n aria-hidden=\"true\"\n size={24}\n className={cn(\n 'shrink-0 text-ods-text-primary transition-transform duration-300',\n isOpen && 'rotate-180',\n )}\n />\n </div>\n {/* Content wrapper. Collapses with the grid 1fr->0fr transition the\n rest of the design system uses (see AnnouncementBar) rather than\n an animated max-height: measuring `scrollHeight` needed a hook\n PER ROW, which meant calling hooks inside `items.map` — the hook\n order then changed whenever `items` did. Grid needs no\n measurement, and it animates correctly when an answer's height\n changes after mount. */}\n <div\n className=\"grid transition-[grid-template-rows,opacity] duration-300 ease-in-out motion-reduce:transition-none\"\n style={{ gridTemplateRows: isOpen ? '1fr' : '0fr', opacity: isOpen ? 1 : 0 }}\n >\n {/* break-words: FAQ answers render as plain text, so a long URL or\n token has no wrap opportunity — and the row is overflow-hidden,\n which would CLIP it past the viewport on mobile. Mirrors the\n markdown-renderer overflow-wrap fix. */}\n <div className=\"overflow-hidden\">\n <div className=\"break-words px-6 pb-4 text-ods-text-primary text-h4\">{item.answer}</div>\n </div>\n </div>\n </div>\n );\n })}\n </div>\n );\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 = '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\n * the bare `<FaqSection>`. Mirrors `LegalDocumentPage` / `DevSectionPage`: the\n * page-level layout lives in the lib, the host page is a thin wrapper that\n * passes only config + the SSR-resolved data.\n *\n * HERO: the title + subtitle route through the canonical (frozen) `PageLayout`\n * `TitleBlock` with `titleSize=\"h1\"` — the unified Help Center header (the\n * `TitleBlock` element is always an `<h1>`; `titleSize` only sets its typography,\n * here `text-h1`). The page owns that `<h1>`, so `<FaqSection heading={null}>`\n * nests its category headings as `<h2>`/`<h3>` (the SEO-recommended FAQ document\n * outline).\n *\n * DATA: pass `initialFaqs` (SSR-resolved, platform-scoped) so `FaqSection`\n * skips its client self-fetch — the standalone page's static platform-only\n * contract. Omit it for embeds that want the self-fetching `/api/faqs`\n * suggestion-fill instead.\n */\n\nimport { useRouter } from '../../embed-shims/next-navigation';\nimport type { Faq } from '../../types/faq';\nimport { PageShell, PageLayout } from '../ui';\nimport { FaqSection } from './faq-section';\nimport type { FaqSchemaOptions } from './json-ld';\n\nexport interface FaqDocumentPageProps {\n /** Page title (frozen `PageLayout` `TitleBlock`). Default \"Frequently Asked Questions\". */\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 /** Render the standalone `<PageShell>` (own `<main>` + bg + max-width). Default\n * true. Pass false when the host layout already provides the page container\n * (e.g. openframe-frontend's `AppLayout` `<main>`) — only the padding box\n * renders, avoiding a nested `<main>`. */\n shell?: boolean;\n /** SSR-hydrate `FaqSection` (skips the client fetch — the platform-only\n * contract for the standalone page). Omit for self-fetching embeds. */\n initialFaqs?: Faq[];\n /** Emit FAQPage schema.org JSON-LD (forwarded to `FaqSection`). Off by\n * default so embeds don't emit duplicate schema. */\n emitJsonLd?: boolean;\n /** JSON-LD name/description/url overrides (forwarded to `FaqSection`). */\n jsonLd?: FaqSchemaOptions;\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 = 'Frequently Asked Questions',\n subtitle,\n backButton,\n initialFaqs,\n emitJsonLd,\n jsonLd,\n apiBaseUrl,\n entityType,\n entityId,\n minResults,\n shell = true,\n}: FaqDocumentPageProps) {\n const router = useRouter();\n\n // Back-button config — mirrors LegalDocumentPage / DevSectionPage. Hide\n // entirely when the caller passes `false` (embed-mode where the host owns\n // 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 const inner = (\n <PageLayout title={title} subtitle={subtitle} backButton={backCfg} titleSize=\"h1\" titleWrap>\n <FaqSection\n initialFaqs={initialFaqs}\n heading={null}\n emitJsonLd={emitJsonLd}\n jsonLd={jsonLd}\n apiBaseUrl={apiBaseUrl}\n entityType={entityType}\n entityId={entityId}\n minResults={minResults}\n />\n </PageLayout>\n );\n\n return shell ? <PageShell>{inner}</PageShell> : <div className=\"page-shell-content\">{inner}</div>;\n}\n"]}
|