@burdenoff/microfe-theculturepost 2026.1205.2 → 2026.1206.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/theculturepost/components/AiContextPanel.js +4 -2
- package/dist/theculturepost/components/AiContextPanel.js.map +1 -1
- package/dist/theculturepost/components/CitationList.js +4 -3
- package/dist/theculturepost/components/CitationList.js.map +1 -1
- package/dist/theculturepost/components/CommunityNorms.js +1 -1
- package/dist/theculturepost/components/CommunityNorms.js.map +1 -1
- package/dist/theculturepost/components/CreateStoryDialog.js +1 -1
- package/dist/theculturepost/components/CreateStoryDialog.js.map +1 -1
- package/dist/theculturepost/components/FramingPrompts.js +1 -1
- package/dist/theculturepost/components/FramingPrompts.js.map +1 -1
- package/dist/theculturepost/components/HistoryTimeline.js +1 -1
- package/dist/theculturepost/components/HistoryTimeline.js.map +1 -1
- package/dist/theculturepost/components/OpenDiscussionDialog.js +1 -1
- package/dist/theculturepost/components/OpenDiscussionDialog.js.map +1 -1
- package/dist/theculturepost/components/PageHero.js +1 -1
- package/dist/theculturepost/components/PageHero.js.map +1 -1
- package/dist/theculturepost/components/ReaderContextDrawer.js +3 -3
- package/dist/theculturepost/components/ReaderContextDrawer.js.map +1 -1
- package/dist/theculturepost/components/RecordOralHistoryDialog.js +1 -1
- package/dist/theculturepost/components/RecordOralHistoryDialog.js.map +1 -1
- package/dist/theculturepost/components/ReplyThread.js +21 -20
- package/dist/theculturepost/components/ReplyThread.js.map +1 -1
- package/dist/theculturepost/components/SourceHealthAndReputation.js +1 -1
- package/dist/theculturepost/components/SourceHealthAndReputation.js.map +1 -1
- package/dist/theculturepost/components/SourceScanLink.js +1 -1
- package/dist/theculturepost/components/SourceScanLink.js.map +1 -1
- package/dist/theculturepost/components/StateViews.d.ts +8 -0
- package/dist/theculturepost/components/StateViews.js +39 -24
- package/dist/theculturepost/components/StateViews.js.map +1 -1
- package/dist/theculturepost/components/StoryCard.js +1 -1
- package/dist/theculturepost/components/StoryCard.js.map +1 -1
- package/dist/theculturepost/components/TopicCard.js +1 -1
- package/dist/theculturepost/components/TopicCard.js.map +1 -1
- package/dist/theculturepost/components/index.d.ts +1 -1
- package/dist/theculturepost/components/index.js +16 -16
- package/dist/theculturepost/hooks/useTcpApi.d.ts +14 -2
- package/dist/theculturepost/hooks/useTcpApi.js +7 -3
- package/dist/theculturepost/hooks/useTcpApi.js.map +1 -1
- package/dist/theculturepost/pages/HomePage.js +56 -56
- package/dist/theculturepost/pages/HomePage.js.map +1 -1
- package/dist/theculturepost/pages/archive/ArchiveItemDetailPage.js +48 -47
- package/dist/theculturepost/pages/archive/ArchiveItemDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/archive/ArchivePage.js +151 -147
- package/dist/theculturepost/pages/archive/ArchivePage.js.map +1 -1
- package/dist/theculturepost/pages/archive/CollectionDetailPage.js +23 -22
- package/dist/theculturepost/pages/archive/CollectionDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/curriculum/CurriculumPage.js +2 -2
- package/dist/theculturepost/pages/curriculum/CurriculumPage.js.map +1 -1
- package/dist/theculturepost/pages/discussions/DiscussionDetailPage.js +11 -10
- package/dist/theculturepost/pages/discussions/DiscussionDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/discussions/DiscussionsPage.js +66 -64
- package/dist/theculturepost/pages/discussions/DiscussionsPage.js.map +1 -1
- package/dist/theculturepost/pages/governance/AiOpsPanel.js +2 -2
- package/dist/theculturepost/pages/governance/AiOpsPanel.js.map +1 -1
- package/dist/theculturepost/pages/governance/ContributorOnboardingPanel.js +1 -1
- package/dist/theculturepost/pages/governance/ContributorOnboardingPanel.js.map +1 -1
- package/dist/theculturepost/pages/governance/GovernancePage.js +168 -167
- package/dist/theculturepost/pages/governance/GovernancePage.js.map +1 -1
- package/dist/theculturepost/pages/governance/TopicSettingsPanel.js +1 -0
- package/dist/theculturepost/pages/governance/TopicSettingsPanel.js.map +1 -1
- package/dist/theculturepost/pages/stories/SavedStoriesPage.js +12 -11
- package/dist/theculturepost/pages/stories/SavedStoriesPage.js.map +1 -1
- package/dist/theculturepost/pages/stories/StoriesPage.js +89 -88
- package/dist/theculturepost/pages/stories/StoriesPage.js.map +1 -1
- package/dist/theculturepost/pages/stories/StoryCitationsPage.js +4 -1
- package/dist/theculturepost/pages/stories/StoryCitationsPage.js.map +1 -1
- package/dist/theculturepost/pages/stories/StoryDetailPage.js +93 -91
- package/dist/theculturepost/pages/stories/StoryDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/studio/ContributorStudioPage.js +3 -3
- package/dist/theculturepost/pages/studio/ContributorStudioPage.js.map +1 -1
- package/dist/theculturepost/pages/timeline/TimelinePage.js +24 -23
- package/dist/theculturepost/pages/timeline/TimelinePage.js.map +1 -1
- package/dist/theculturepost/pages/topics/TopicDetailPage.js +124 -123
- package/dist/theculturepost/pages/topics/TopicDetailPage.js.map +1 -1
- package/dist/theculturepost/pages/topics/TopicsPage.js +65 -62
- package/dist/theculturepost/pages/topics/TopicsPage.js.map +1 -1
- package/dist/theculturepost/utils/permissions.d.ts +18 -0
- package/dist/theculturepost/utils/permissions.js +7 -0
- package/dist/theculturepost/utils/permissions.js.map +1 -0
- package/package.json +2 -2
|
@@ -266,7 +266,7 @@ function z({ storyId: t, collectionId: a, oralHistoryId: o, useCases: s, title:
|
|
|
266
266
|
className: "flex items-center gap-2 font-display text-xl font-semibold text-text-primary",
|
|
267
267
|
children: [
|
|
268
268
|
/* @__PURE__ */ y(g, {
|
|
269
|
-
className: "h-5 w-5 text-
|
|
269
|
+
className: "h-5 w-5 text-text-link",
|
|
270
270
|
"aria-hidden": "true"
|
|
271
271
|
}),
|
|
272
272
|
" ",
|
|
@@ -292,6 +292,7 @@ function z({ storyId: t, collectionId: a, oralHistoryId: o, useCases: s, title:
|
|
|
292
292
|
})]
|
|
293
293
|
}),
|
|
294
294
|
O && (k.isLoading ? /* @__PURE__ */ y(r, { label: "Loading AI runs…" }) : k.isError ? /* @__PURE__ */ y(n, {
|
|
295
|
+
error: k.error,
|
|
295
296
|
title: "Could not load AI runs",
|
|
296
297
|
onRetry: () => k.refetch()
|
|
297
298
|
}) : A.length === 0 ? /* @__PURE__ */ y(S, {
|
|
@@ -336,6 +337,7 @@ function B({ className: t }) {
|
|
|
336
337
|
function V({ className: e, canReview: t }) {
|
|
337
338
|
let a = i({ pagination: { limit: 50 } }), o = (a.data?.items ?? []).filter(l);
|
|
338
339
|
return a.isLoading ? /* @__PURE__ */ y(r, { label: "Loading AI review queue…" }) : a.isError ? /* @__PURE__ */ y(n, {
|
|
340
|
+
error: a.error,
|
|
339
341
|
title: "Could not load the AI review queue",
|
|
340
342
|
onRetry: () => a.refetch()
|
|
341
343
|
}) : o.length === 0 ? null : /* @__PURE__ */ b(C, {
|
|
@@ -346,7 +348,7 @@ function V({ className: e, canReview: t }) {
|
|
|
346
348
|
className: "flex items-center gap-2 font-display text-xl font-semibold text-text-primary",
|
|
347
349
|
children: [
|
|
348
350
|
/* @__PURE__ */ y(g, {
|
|
349
|
-
className: "h-5 w-5 text-
|
|
351
|
+
className: "h-5 w-5 text-text-link",
|
|
350
352
|
"aria-hidden": "true"
|
|
351
353
|
}),
|
|
352
354
|
" AI review queue",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiContextPanel.js","names":["_Fragment","Fragment$1","AI_USE_CASE_LABELS","DEFAULT_PROMPTS","GROUNDING_KIND_LABELS","GenerateAiContextDialog","generate","useTcpGenerateAiContext","prompt","setPrompt","useState","useCase","run","setRun","reset","nextOpen","onOpenChange","submit","input","storyId","collectionId","oralHistoryId","created","onGenerated","error","describeError","statusNote","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","AiRunCard","Label","Textarea","event","ResponsiveDialogFooter","Button","Sparkles","UNCERTAINTY_BADGE","review","useTcpReviewAiContext","notes","setNotes","expanded","setExpanded","defaultExpanded","decide","updated","onReviewed","notify","approved","GlassCard","StatusBadge","formatEnumLabel","formatRelativeTime","value","ref","canReview","isReviewableAiRun","Check","X","AiContextSection","useTheCulturePost","permissions","useSafePermissions","resolveAiContextPermissions","workspaceId","activeUseCase","setActiveUseCase","listable","canRead","runsQuery","useTcpAiContextRuns","canCreate","runs","pendingCount","FeatureGate","className","title","description","useCases","LoadingView","ErrorView","EmptyState","open","AiReviewQueue","AiReviewQueueContent","items"],"sources":["../../../src/theculturepost/components/AiContextPanel.tsx"],"sourcesContent":["/**\n * AiContextPanel — in-app UI for the citation-grounded AI context layer.\n * @module theculturepost/components\n *\n * Surfaces the `tcpGenerateAiContext` / `tcpReviewAiContext` / `tcpAiContextRuns`\n * operations (BOFF-4127) so editors can generate, review and adopt\n * citation-grounded answers without leaving the story, collection or oral\n * history screen (BOFF-5805).\n *\n * Floors stay server-side: generation is feature-flagged, grounding only ever\n * reads PUBLIC/COMMUNITY sources, and every run lands PENDING until a human\n * approves or rejects it. This UI only calls those operations and renders\n * their results — RBAC and access-tier denials surface as errors.\n */\n\nimport { useState } from 'react';\nimport { Check, Sparkles, X } from 'lucide-react';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n GlassCard,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Textarea,\n EmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTheCulturePost } from '../context';\nimport { useTcpAiContextRuns, useTcpGenerateAiContext, useTcpReviewAiContext } from '../hooks';\nimport { notify, describeError } from '../lib/toast';\nimport { isReviewableAiRun, resolveAiContextPermissions } from '../utils/aiContextPermissions';\nimport { formatEnumLabel, formatRelativeTime } from '../utils/formatters';\nimport type {\n TcpAgentRun,\n TcpAiGroundingKind,\n TcpAiUseCase,\n TcpGenerateAiContextInput,\n} from '../types';\n\n// ============================================================================\n// Per-use-case presentation metadata (labels + default prompts)\n// ============================================================================\n\nexport const AI_USE_CASE_LABELS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'Summarise evidence',\n DRAFT_FRAMING_PROMPT: 'Draft framing',\n SUGGEST_RELATED_TRADITIONS: 'Find related traditions',\n TRANSCRIBE_ORAL_HISTORY: 'Clean up transcript',\n VERIFY_CITATION: 'Verify citation proposal',\n ASSESS_SOURCE_HEALTH: 'Assess source health',\n SENSITIVITY_FRAMING: 'Sensitivity framing review',\n EXPLAIN_TERM: 'Explain term',\n TRANSLATE_STORY: 'Translate story draft',\n EDITORIAL_SWEEP: 'Editorial sweep',\n ANALYZE_ARCHIVE_IMAGE: 'Analyze archive image',\n GENERATE_SUBTITLES: 'Generate subtitles',\n SPEECH_TO_TEXT: 'Speech-to-text transcript',\n};\n\nconst DEFAULT_PROMPTS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'What do the cited sources say about this story’s central claims?',\n DRAFT_FRAMING_PROMPT:\n 'Draft a short framing question that an editor could put to the cited sources.',\n SUGGEST_RELATED_TRADITIONS:\n 'Which traditions or practices in this collection relate to each other, and why?',\n TRANSCRIBE_ORAL_HISTORY:\n 'Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.',\n VERIFY_CITATION: 'Propose a verification status grounded strictly in this citation and excerpt.',\n ASSESS_SOURCE_HEALTH: 'Assess reachability and strength of all citations on this story.',\n SENSITIVITY_FRAMING: 'Flag any framing concerns with respectful reframing suggestions.',\n EXPLAIN_TERM: 'Explain this term using only eligible workspace sources, or abstain.',\n TRANSLATE_STORY: 'Draft a reviewable translation of this story into the requested locale.',\n EDITORIAL_SWEEP: 'Run scheduled source-health, review-queue, and embargo watch sweep.',\n ANALYZE_ARCHIVE_IMAGE:\n 'Propose respectful archival description and candidate tags for this image.',\n GENERATE_SUBTITLES: 'Draft WebVTT subtitles from consented oral history testimony.',\n SPEECH_TO_TEXT: 'Draft speech-to-text transcript proposal for editorial review.',\n};\n\nconst GROUNDING_KIND_LABELS: Record<TcpAiGroundingKind, string> = {\n CITATION: 'Citation',\n ARCHIVE_ITEM: 'Artifact',\n ORAL_HISTORY: 'Oral history',\n};\n\n// ============================================================================\n// Generate dialog\n// ============================================================================\n\nexport interface GenerateAiContextDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Preselected use case. Locked to this single action. */\n useCase: TcpAiUseCase;\n /** Exactly one grounding scope, matching the svc input contract. */\n storyId?: string;\n collectionId?: string;\n oralHistoryId?: string;\n /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */\n canReview?: boolean;\n onGenerated?: (run: TcpAgentRun) => void;\n}\n\nexport function GenerateAiContextDialog({\n open,\n onOpenChange,\n useCase,\n storyId,\n collectionId,\n oralHistoryId,\n canReview = true,\n onGenerated,\n}: GenerateAiContextDialogProps) {\n const generate = useTcpGenerateAiContext();\n const [prompt, setPrompt] = useState(() => DEFAULT_PROMPTS[useCase]);\n const [run, setRun] = useState<TcpAgentRun | null>(null);\n\n const reset = (nextOpen: boolean) => {\n if (!nextOpen) {\n setPrompt(DEFAULT_PROMPTS[useCase]);\n setRun(null);\n generate.reset();\n }\n onOpenChange(nextOpen);\n };\n\n const submit = async () => {\n const input: TcpGenerateAiContextInput = {\n useCase,\n prompt: prompt.trim(),\n storyId: storyId ?? null,\n collectionId: collectionId ?? null,\n oralHistoryId: oralHistoryId ?? null,\n };\n try {\n const created = await generate.mutateAsync(input);\n setRun(created);\n onGenerated?.(created);\n } catch (error) {\n notify.error('Generation failed', describeError(error));\n }\n };\n\n const statusNote =\n run?.reviewStatus === 'APPROVED'\n ? 'Run approved — recorded in the editorial log.'\n : run?.reviewStatus === 'REJECTED'\n ? 'Run rejected — kept on record.'\n : 'Run created — it is awaiting editorial review.';\n\n return (\n <ResponsiveDialog open={open} onOpenChange={reset}>\n <ResponsiveDialogContent className=\"sm:max-w-xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{AI_USE_CASE_LABELS[useCase]}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY).\n Every run starts as pending editorial review — nothing is adopted automatically.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {run ? (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-sm text-text-secondary\">{statusNote}</p>\n <AiRunCard run={run} canReview={canReview} defaultExpanded onReviewed={setRun} />\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor=\"ai-context-prompt\">Your question or instruction</Label>\n <Textarea\n id=\"ai-context-prompt\"\n value={prompt}\n onChange={(event) => setPrompt(event.target.value)}\n rows={4}\n disabled={generate.isPending}\n />\n <p className=\"text-xs text-text-tertiary\">\n Combined server-side with the grounded sources — never sent to the model alone.\n </p>\n </div>\n )}\n\n <ResponsiveDialogFooter>\n {run ? (\n <Button onClick={() => reset(false)}>Done</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => reset(false)} disabled={generate.isPending}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={generate.isPending || !prompt.trim()}>\n <Sparkles className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {generate.isPending ? 'Generating…' : 'Generate'}\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\n// ============================================================================\n// Run card (list item + inline review)\n// ============================================================================\n\nconst UNCERTAINTY_BADGE: Record<string, 'success' | 'warning' | 'destructive'> = {\n LOW: 'success',\n MEDIUM: 'warning',\n HIGH: 'destructive',\n};\n\nexport interface AiRunCardProps {\n run: TcpAgentRun;\n canReview?: boolean;\n defaultExpanded?: boolean;\n onReviewed?: (updated: TcpAgentRun) => void;\n}\n\nexport function AiRunCard({\n run,\n canReview = true,\n defaultExpanded = false,\n onReviewed,\n}: AiRunCardProps) {\n const review = useTcpReviewAiContext();\n const [notes, setNotes] = useState('');\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const decide = async (approved: boolean) => {\n try {\n const updated = await review.mutateAsync({\n id: run.id,\n approved,\n reviewNotes: notes.trim() || undefined,\n });\n onReviewed?.(updated);\n notify.success(\n approved ? 'AI answer approved' : 'AI answer rejected',\n approved ? 'It is now marked as reviewed.' : 'The run stays on record as rejected.'\n );\n } catch (error) {\n notify.error('Review failed', describeError(error));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <StatusBadge status={run.useCase} />\n {run.status === 'FAILED' ? (\n <StatusBadge status=\"FAILED\" />\n ) : (\n <StatusBadge status={run.reviewStatus} />\n )}\n {run.uncertainty && (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${\n UNCERTAINTY_BADGE[run.uncertainty] === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : UNCERTAINTY_BADGE[run.uncertainty] === 'destructive'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n }`}\n >\n Uncertainty: {formatEnumLabel(run.uncertainty)}\n </span>\n )}\n <span className=\"ms-auto text-xs text-text-tertiary\">\n {formatRelativeTime(run.createdAt)}\n </span>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Prompt: </span>\n {run.promptSummary}\n </p>\n\n {run.error && (\n <p className=\"rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n {run.content && (\n <div>\n <button\n type=\"button\"\n onClick={() => setExpanded((value) => !value)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:underline\"\n >\n {expanded ? 'Hide answer' : 'Show answer'}\n </button>\n {expanded && (\n <p className=\"mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary\">\n {run.content}\n </p>\n )}\n </div>\n )}\n\n {run.groundingRefs.length > 0 && (\n <div className=\"flex flex-col gap-1.5\">\n <p className=\"text-xs font-medium text-text-tertiary\">\n Grounded in ({run.groundingRefs.length} sources)\n </p>\n <ul className=\"flex flex-wrap gap-1.5\">\n {run.groundingRefs.map((ref) => (\n <li\n key={`${ref.kind}-${ref.refId}`}\n className=\"inline-flex max-w-full items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n title={ref.title}\n >\n <span className=\"shrink-0 font-medium\">\n {GROUNDING_KIND_LABELS[ref.kind] ?? formatEnumLabel(ref.kind)}\n </span>\n <span className=\"truncate\">{ref.title}</span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {run.reviewStatus !== 'PENDING' && (run.reviewNotes || run.reviewedAt) && (\n <p className=\"text-xs text-text-tertiary\">\n {run.reviewStatus === 'APPROVED' ? 'Approved' : 'Rejected'}\n {run.reviewNotes ? ` — ${run.reviewNotes}` : ''}\n </p>\n )}\n\n {canReview && isReviewableAiRun(run) && (\n <div className=\"flex flex-col gap-2 border-t border-border-seam pt-3\">\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n rows={2}\n placeholder=\"Review notes (optional)\"\n disabled={review.isPending}\n />\n <div className=\"flex gap-2\">\n <Button\n size=\"sm\"\n onClick={() => decide(true)}\n disabled={review.isPending}\n aria-label=\"Approve AI answer\"\n >\n <Check className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => decide(false)}\n disabled={review.isPending}\n aria-label=\"Reject AI answer\"\n >\n <X className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Reject\n </Button>\n </div>\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ============================================================================\n// Section: action buttons + run list for one grounding scope\n// ============================================================================\n\nexport interface AiContextSectionProps {\n /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */\n storyId?: string;\n /** Collection-scoped use cases (SUGGEST_RELATED_TRADITIONS). */\n collectionId?: string;\n /** Oral-history use case (TRANSCRIBE_ORAL_HISTORY) — action only, no run list\n * filter exists for oral histories server-side. */\n oralHistoryId?: string;\n useCases: TcpAiUseCase[];\n title?: string;\n description?: string;\n className?: string;\n}\n\nexport function AiContextSection({\n storyId,\n collectionId,\n oralHistoryId,\n useCases,\n title = 'AI assistant',\n description = 'Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.',\n className,\n}: AiContextSectionProps) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canCreate, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n const [activeUseCase, setActiveUseCase] = useState<TcpAiUseCase | null>(null);\n // Runs are listable per story or collection; the svc has no oralHistoryId filter.\n const listable = Boolean(storyId || collectionId) && canRead;\n const runsQuery = useTcpAiContextRuns({\n storyId,\n collectionId,\n pagination: { limit: 10 },\n enabled: listable,\n });\n\n if (!canRead && !canCreate) {\n return null;\n }\n\n const runs = listable ? (runsQuery.data?.items ?? []) : [];\n const pendingCount = runs.filter(isReviewableAiRun).length;\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-4 p-5 sm:p-6 ${className ?? ''}`}>\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> {title}\n {pendingCount > 0 && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {pendingCount} pending\n </span>\n )}\n </h2>\n <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>\n </div>\n {canCreate && (\n <div className=\"flex flex-wrap gap-2\">\n {useCases.map((useCase) => (\n <Button key={useCase} variant=\"outline\" onClick={() => setActiveUseCase(useCase)}>\n <Sparkles className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {AI_USE_CASE_LABELS[useCase]}\n </Button>\n ))}\n </div>\n )}\n </div>\n\n {listable &&\n (runsQuery.isLoading ? (\n <LoadingView label=\"Loading AI runs…\" />\n ) : runsQuery.isError ? (\n <ErrorView title=\"Could not load AI runs\" onRetry={() => runsQuery.refetch()} />\n ) : runs.length === 0 ? (\n <EmptyState\n size=\"panel\"\n icon={<Sparkles className=\"h-9 w-9\" />}\n title=\"No AI runs yet\"\n description={\n canCreate\n ? 'Run one of the actions above to draft a citation-grounded answer.'\n : 'No citation-grounded AI runs have been created for this scope yet.'\n }\n />\n ) : (\n <div className=\"flex flex-col gap-3\">\n {runs.map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n </div>\n ))}\n\n {activeUseCase && (\n <GenerateAiContextDialog\n open\n onOpenChange={(open) => {\n if (!open) setActiveUseCase(null);\n }}\n useCase={activeUseCase}\n storyId={storyId}\n collectionId={collectionId}\n oralHistoryId={oralHistoryId}\n canReview={canReview}\n />\n )}\n </GlassCard>\n </FeatureGate>\n );\n}\n\n// ============================================================================\n// Editorial review queue (workspace-wide, StoriesPage overview)\n// ============================================================================\n\nexport function AiReviewQueue({ className }: { className?: string }) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n\n if (!canRead) {\n return null;\n }\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <AiReviewQueueContent className={className} canReview={canReview} />\n </FeatureGate>\n );\n}\n\nfunction AiReviewQueueContent({\n className,\n canReview,\n}: {\n className?: string;\n canReview: boolean;\n}) {\n const runsQuery = useTcpAiContextRuns({ pagination: { limit: 50 } });\n const items = (runsQuery.data?.items ?? []).filter(isReviewableAiRun);\n\n if (runsQuery.isLoading) {\n return <LoadingView label=\"Loading AI review queue…\" />;\n }\n if (runsQuery.isError) {\n return (\n <ErrorView title=\"Could not load the AI review queue\" onRetry={() => runsQuery.refetch()} />\n );\n }\n if (items.length === 0) {\n return null;\n }\n\n return (\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-3 p-5 sm:p-6 ${className ?? ''}`}>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-accent\" aria-hidden=\"true\" /> AI review queue\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {items.length} pending\n </span>\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Generated answers awaiting an editorial decision, newest first. Approve or reject them here,\n or in place on the story or collection they belong to.\n </p>\n <div className=\"flex flex-col gap-3\">\n {items.slice(0, 5).map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n {items.length > 5 && (\n <p className=\"text-xs text-text-tertiary\">\n {items.length - 5} more pending — open the story or collection they belong to review\n them in place.\n </p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkDA,IAAaE,IAAmD;CAC9D,oBAAoB;CACpB,sBAAsB;CACtB,4BAA4B;CAC5B,yBAAyB;CACzB,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBAAuB;CACvB,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAAgD;CACpD,oBAAoB;CACpB,sBACE;CACF,4BACE;CACF,yBACE;CACF,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBACE;CACF,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAA4D;CAChE,UAAU;CACV,cAAc;CACd,cAAc;AAChB;AAoBA,SAAgBC,EAAwB,EACtC,SACA,iBACA,YACA,YACA,iBACA,kBACA,e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;IAAI,WAAU;IAAd,UAAA;KACE,kBAACxC,GAAD;MAAU,WAAU;MAAsB,eAAY;KAAQ,CAAA;KAAC;KAC/D,kBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACGkD,EAAM,QAAO,UACV;;IACJ;;GACJ,kBAAC,KAAD;IAAG,WAAU;IAA8B,UAAA;GAGxC,CAAA;GACH,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGA,EAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAACxD,GAAD;KAA6B;KAAgB;IAAY,GAAzCpB,EAAI,EAAqC,CAC1D,GACA4E,EAAM,SAAS,KACd,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA,CACGA,EAAM,SAAS,GAAE,mFAEjB;IAEF,CAAA,CAAA;;EACI;;AAEf"}
|
|
1
|
+
{"version":3,"file":"AiContextPanel.js","names":["_Fragment","Fragment$1","AI_USE_CASE_LABELS","DEFAULT_PROMPTS","GROUNDING_KIND_LABELS","GenerateAiContextDialog","generate","useTcpGenerateAiContext","prompt","setPrompt","useState","useCase","run","setRun","reset","nextOpen","onOpenChange","submit","input","storyId","collectionId","oralHistoryId","created","onGenerated","error","describeError","statusNote","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","AiRunCard","Label","Textarea","event","ResponsiveDialogFooter","Button","Sparkles","UNCERTAINTY_BADGE","review","useTcpReviewAiContext","notes","setNotes","expanded","setExpanded","defaultExpanded","decide","updated","onReviewed","notify","approved","GlassCard","StatusBadge","formatEnumLabel","formatRelativeTime","value","ref","canReview","isReviewableAiRun","Check","X","AiContextSection","useTheCulturePost","permissions","useSafePermissions","resolveAiContextPermissions","workspaceId","activeUseCase","setActiveUseCase","listable","canRead","runsQuery","useTcpAiContextRuns","canCreate","runs","pendingCount","FeatureGate","className","title","description","useCases","LoadingView","ErrorView","EmptyState","open","AiReviewQueue","AiReviewQueueContent","items"],"sources":["../../../src/theculturepost/components/AiContextPanel.tsx"],"sourcesContent":["/**\n * AiContextPanel — in-app UI for the citation-grounded AI context layer.\n * @module theculturepost/components\n *\n * Surfaces the `tcpGenerateAiContext` / `tcpReviewAiContext` / `tcpAiContextRuns`\n * operations (BOFF-4127) so editors can generate, review and adopt\n * citation-grounded answers without leaving the story, collection or oral\n * history screen (BOFF-5805).\n *\n * Floors stay server-side: generation is feature-flagged, grounding only ever\n * reads PUBLIC/COMMUNITY sources, and every run lands PENDING until a human\n * approves or rejects it. This UI only calls those operations and renders\n * their results — RBAC and access-tier denials surface as errors.\n */\n\nimport { useState } from 'react';\nimport { Check, Sparkles, X } from 'lucide-react';\nimport { FeatureGate } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSafePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n Button,\n GlassCard,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Textarea,\n EmptyState,\n} from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTheCulturePost } from '../context';\nimport { useTcpAiContextRuns, useTcpGenerateAiContext, useTcpReviewAiContext } from '../hooks';\nimport { notify, describeError } from '../lib/toast';\nimport { isReviewableAiRun, resolveAiContextPermissions } from '../utils/aiContextPermissions';\nimport { formatEnumLabel, formatRelativeTime } from '../utils/formatters';\nimport type {\n TcpAgentRun,\n TcpAiGroundingKind,\n TcpAiUseCase,\n TcpGenerateAiContextInput,\n} from '../types';\n\n// ============================================================================\n// Per-use-case presentation metadata (labels + default prompts)\n// ============================================================================\n\nexport const AI_USE_CASE_LABELS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'Summarise evidence',\n DRAFT_FRAMING_PROMPT: 'Draft framing',\n SUGGEST_RELATED_TRADITIONS: 'Find related traditions',\n TRANSCRIBE_ORAL_HISTORY: 'Clean up transcript',\n VERIFY_CITATION: 'Verify citation proposal',\n ASSESS_SOURCE_HEALTH: 'Assess source health',\n SENSITIVITY_FRAMING: 'Sensitivity framing review',\n EXPLAIN_TERM: 'Explain term',\n TRANSLATE_STORY: 'Translate story draft',\n EDITORIAL_SWEEP: 'Editorial sweep',\n ANALYZE_ARCHIVE_IMAGE: 'Analyze archive image',\n GENERATE_SUBTITLES: 'Generate subtitles',\n SPEECH_TO_TEXT: 'Speech-to-text transcript',\n};\n\nconst DEFAULT_PROMPTS: Record<TcpAiUseCase, string> = {\n SUMMARIZE_EVIDENCE: 'What do the cited sources say about this story’s central claims?',\n DRAFT_FRAMING_PROMPT:\n 'Draft a short framing question that an editor could put to the cited sources.',\n SUGGEST_RELATED_TRADITIONS:\n 'Which traditions or practices in this collection relate to each other, and why?',\n TRANSCRIBE_ORAL_HISTORY:\n 'Clean up and format this transcript: fix punctuation and paragraph breaks, and mark speaker turns — do not add any content that is not in the original.',\n VERIFY_CITATION: 'Propose a verification status grounded strictly in this citation and excerpt.',\n ASSESS_SOURCE_HEALTH: 'Assess reachability and strength of all citations on this story.',\n SENSITIVITY_FRAMING: 'Flag any framing concerns with respectful reframing suggestions.',\n EXPLAIN_TERM: 'Explain this term using only eligible workspace sources, or abstain.',\n TRANSLATE_STORY: 'Draft a reviewable translation of this story into the requested locale.',\n EDITORIAL_SWEEP: 'Run scheduled source-health, review-queue, and embargo watch sweep.',\n ANALYZE_ARCHIVE_IMAGE:\n 'Propose respectful archival description and candidate tags for this image.',\n GENERATE_SUBTITLES: 'Draft WebVTT subtitles from consented oral history testimony.',\n SPEECH_TO_TEXT: 'Draft speech-to-text transcript proposal for editorial review.',\n};\n\nconst GROUNDING_KIND_LABELS: Record<TcpAiGroundingKind, string> = {\n CITATION: 'Citation',\n ARCHIVE_ITEM: 'Artifact',\n ORAL_HISTORY: 'Oral history',\n};\n\n// ============================================================================\n// Generate dialog\n// ============================================================================\n\nexport interface GenerateAiContextDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Preselected use case. Locked to this single action. */\n useCase: TcpAiUseCase;\n /** Exactly one grounding scope, matching the svc input contract. */\n storyId?: string;\n collectionId?: string;\n oralHistoryId?: string;\n /** Whether the caller holds `theculturepost-ai-context:update` to review inline. */\n canReview?: boolean;\n onGenerated?: (run: TcpAgentRun) => void;\n}\n\nexport function GenerateAiContextDialog({\n open,\n onOpenChange,\n useCase,\n storyId,\n collectionId,\n oralHistoryId,\n canReview = true,\n onGenerated,\n}: GenerateAiContextDialogProps) {\n const generate = useTcpGenerateAiContext();\n const [prompt, setPrompt] = useState(() => DEFAULT_PROMPTS[useCase]);\n const [run, setRun] = useState<TcpAgentRun | null>(null);\n\n const reset = (nextOpen: boolean) => {\n if (!nextOpen) {\n setPrompt(DEFAULT_PROMPTS[useCase]);\n setRun(null);\n generate.reset();\n }\n onOpenChange(nextOpen);\n };\n\n const submit = async () => {\n const input: TcpGenerateAiContextInput = {\n useCase,\n prompt: prompt.trim(),\n storyId: storyId ?? null,\n collectionId: collectionId ?? null,\n oralHistoryId: oralHistoryId ?? null,\n };\n try {\n const created = await generate.mutateAsync(input);\n setRun(created);\n onGenerated?.(created);\n } catch (error) {\n notify.error('Generation failed', describeError(error));\n }\n };\n\n const statusNote =\n run?.reviewStatus === 'APPROVED'\n ? 'Run approved — recorded in the editorial log.'\n : run?.reviewStatus === 'REJECTED'\n ? 'Run rejected — kept on record.'\n : 'Run created — it is awaiting editorial review.';\n\n return (\n <ResponsiveDialog open={open} onOpenChange={reset}>\n <ResponsiveDialogContent className=\"sm:max-w-xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{AI_USE_CASE_LABELS[useCase]}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Runs on this product’s AI answer only from sources you can read (PUBLIC/COMMUNITY).\n Every run starts as pending editorial review — nothing is adopted automatically.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n {run ? (\n <div className=\"flex flex-col gap-4\">\n <p className=\"text-sm text-text-secondary\">{statusNote}</p>\n <AiRunCard run={run} canReview={canReview} defaultExpanded onReviewed={setRun} />\n </div>\n ) : (\n <div className=\"flex flex-col gap-2\">\n <Label htmlFor=\"ai-context-prompt\">Your question or instruction</Label>\n <Textarea\n id=\"ai-context-prompt\"\n value={prompt}\n onChange={(event) => setPrompt(event.target.value)}\n rows={4}\n disabled={generate.isPending}\n />\n <p className=\"text-xs text-text-tertiary\">\n Combined server-side with the grounded sources — never sent to the model alone.\n </p>\n </div>\n )}\n\n <ResponsiveDialogFooter>\n {run ? (\n <Button onClick={() => reset(false)}>Done</Button>\n ) : (\n <>\n <Button variant=\"outline\" onClick={() => reset(false)} disabled={generate.isPending}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={generate.isPending || !prompt.trim()}>\n <Sparkles className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {generate.isPending ? 'Generating…' : 'Generate'}\n </Button>\n </>\n )}\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\n// ============================================================================\n// Run card (list item + inline review)\n// ============================================================================\n\nconst UNCERTAINTY_BADGE: Record<string, 'success' | 'warning' | 'destructive'> = {\n LOW: 'success',\n MEDIUM: 'warning',\n HIGH: 'destructive',\n};\n\nexport interface AiRunCardProps {\n run: TcpAgentRun;\n canReview?: boolean;\n defaultExpanded?: boolean;\n onReviewed?: (updated: TcpAgentRun) => void;\n}\n\nexport function AiRunCard({\n run,\n canReview = true,\n defaultExpanded = false,\n onReviewed,\n}: AiRunCardProps) {\n const review = useTcpReviewAiContext();\n const [notes, setNotes] = useState('');\n const [expanded, setExpanded] = useState(defaultExpanded);\n\n const decide = async (approved: boolean) => {\n try {\n const updated = await review.mutateAsync({\n id: run.id,\n approved,\n reviewNotes: notes.trim() || undefined,\n });\n onReviewed?.(updated);\n notify.success(\n approved ? 'AI answer approved' : 'AI answer rejected',\n approved ? 'It is now marked as reviewed.' : 'The run stays on record as rejected.'\n );\n } catch (error) {\n notify.error('Review failed', describeError(error));\n }\n };\n\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex flex-wrap items-center gap-1.5\">\n <StatusBadge status={run.useCase} />\n {run.status === 'FAILED' ? (\n <StatusBadge status=\"FAILED\" />\n ) : (\n <StatusBadge status={run.reviewStatus} />\n )}\n {run.uncertainty && (\n <span\n className={`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${\n UNCERTAINTY_BADGE[run.uncertainty] === 'success'\n ? 'bg-status-success-bg-subtle text-status-success-text'\n : UNCERTAINTY_BADGE[run.uncertainty] === 'destructive'\n ? 'bg-status-error-bg-subtle text-status-error-text'\n : 'bg-status-warning-bg-subtle text-status-warning-text'\n }`}\n >\n Uncertainty: {formatEnumLabel(run.uncertainty)}\n </span>\n )}\n <span className=\"ms-auto text-xs text-text-tertiary\">\n {formatRelativeTime(run.createdAt)}\n </span>\n </div>\n\n <p className=\"text-sm text-text-secondary\">\n <span className=\"font-medium text-text-primary\">Prompt: </span>\n {run.promptSummary}\n </p>\n\n {run.error && (\n <p className=\"rounded-lg bg-status-error-bg-subtle p-2 text-xs text-status-error-text\">\n {run.error}\n </p>\n )}\n\n {run.content && (\n <div>\n <button\n type=\"button\"\n onClick={() => setExpanded((value) => !value)}\n className=\"text-xs font-medium text-text-secondary underline-offset-2 hover:underline\"\n >\n {expanded ? 'Hide answer' : 'Show answer'}\n </button>\n {expanded && (\n <p className=\"mt-2 whitespace-pre-wrap rounded-lg bg-bg-sunken p-3 text-sm text-text-primary\">\n {run.content}\n </p>\n )}\n </div>\n )}\n\n {run.groundingRefs.length > 0 && (\n <div className=\"flex flex-col gap-1.5\">\n <p className=\"text-xs font-medium text-text-tertiary\">\n Grounded in ({run.groundingRefs.length} sources)\n </p>\n <ul className=\"flex flex-wrap gap-1.5\">\n {run.groundingRefs.map((ref) => (\n <li\n key={`${ref.kind}-${ref.refId}`}\n className=\"inline-flex max-w-full items-center gap-1 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs text-text-secondary\"\n title={ref.title}\n >\n <span className=\"shrink-0 font-medium\">\n {GROUNDING_KIND_LABELS[ref.kind] ?? formatEnumLabel(ref.kind)}\n </span>\n <span className=\"truncate\">{ref.title}</span>\n </li>\n ))}\n </ul>\n </div>\n )}\n\n {run.reviewStatus !== 'PENDING' && (run.reviewNotes || run.reviewedAt) && (\n <p className=\"text-xs text-text-tertiary\">\n {run.reviewStatus === 'APPROVED' ? 'Approved' : 'Rejected'}\n {run.reviewNotes ? ` — ${run.reviewNotes}` : ''}\n </p>\n )}\n\n {canReview && isReviewableAiRun(run) && (\n <div className=\"flex flex-col gap-2 border-t border-border-seam pt-3\">\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n rows={2}\n placeholder=\"Review notes (optional)\"\n disabled={review.isPending}\n />\n <div className=\"flex gap-2\">\n <Button\n size=\"sm\"\n onClick={() => decide(true)}\n disabled={review.isPending}\n aria-label=\"Approve AI answer\"\n >\n <Check className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Approve\n </Button>\n <Button\n size=\"sm\"\n variant=\"outline\"\n onClick={() => decide(false)}\n disabled={review.isPending}\n aria-label=\"Reject AI answer\"\n >\n <X className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" /> Reject\n </Button>\n </div>\n </div>\n )}\n </GlassCard>\n );\n}\n\n// ============================================================================\n// Section: action buttons + run list for one grounding scope\n// ============================================================================\n\nexport interface AiContextSectionProps {\n /** Story-scoped use cases (SUMMARIZE_EVIDENCE, DRAFT_FRAMING_PROMPT). */\n storyId?: string;\n /** Collection-scoped use cases (SUGGEST_RELATED_TRADITIONS). */\n collectionId?: string;\n /** Oral-history use case (TRANSCRIBE_ORAL_HISTORY) — action only, no run list\n * filter exists for oral histories server-side. */\n oralHistoryId?: string;\n useCases: TcpAiUseCase[];\n title?: string;\n description?: string;\n className?: string;\n}\n\nexport function AiContextSection({\n storyId,\n collectionId,\n oralHistoryId,\n useCases,\n title = 'AI assistant',\n description = 'Citation-grounded answers from sources you can read. Every answer waits for editorial review before adoption.',\n className,\n}: AiContextSectionProps) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canCreate, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n const [activeUseCase, setActiveUseCase] = useState<TcpAiUseCase | null>(null);\n // Runs are listable per story or collection; the svc has no oralHistoryId filter.\n const listable = Boolean(storyId || collectionId) && canRead;\n const runsQuery = useTcpAiContextRuns({\n storyId,\n collectionId,\n pagination: { limit: 10 },\n enabled: listable,\n });\n\n if (!canRead && !canCreate) {\n return null;\n }\n\n const runs = listable ? (runsQuery.data?.items ?? []) : [];\n const pendingCount = runs.filter(isReviewableAiRun).length;\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-4 p-5 sm:p-6 ${className ?? ''}`}>\n <div className=\"flex flex-wrap items-start justify-between gap-3\">\n <div>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-text-link\" aria-hidden=\"true\" /> {title}\n {pendingCount > 0 && (\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {pendingCount} pending\n </span>\n )}\n </h2>\n <p className=\"mt-1 text-sm text-text-secondary\">{description}</p>\n </div>\n {canCreate && (\n <div className=\"flex flex-wrap gap-2\">\n {useCases.map((useCase) => (\n <Button key={useCase} variant=\"outline\" onClick={() => setActiveUseCase(useCase)}>\n <Sparkles className=\"me-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {AI_USE_CASE_LABELS[useCase]}\n </Button>\n ))}\n </div>\n )}\n </div>\n\n {listable &&\n (runsQuery.isLoading ? (\n <LoadingView label=\"Loading AI runs…\" />\n ) : runsQuery.isError ? (\n <ErrorView\n error={runsQuery.error}\n title=\"Could not load AI runs\"\n onRetry={() => runsQuery.refetch()}\n />\n ) : runs.length === 0 ? (\n <EmptyState\n size=\"panel\"\n icon={<Sparkles className=\"h-9 w-9\" />}\n title=\"No AI runs yet\"\n description={\n canCreate\n ? 'Run one of the actions above to draft a citation-grounded answer.'\n : 'No citation-grounded AI runs have been created for this scope yet.'\n }\n />\n ) : (\n <div className=\"flex flex-col gap-3\">\n {runs.map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n </div>\n ))}\n\n {activeUseCase && (\n <GenerateAiContextDialog\n open\n onOpenChange={(open) => {\n if (!open) setActiveUseCase(null);\n }}\n useCase={activeUseCase}\n storyId={storyId}\n collectionId={collectionId}\n oralHistoryId={oralHistoryId}\n canReview={canReview}\n />\n )}\n </GlassCard>\n </FeatureGate>\n );\n}\n\n// ============================================================================\n// Editorial review queue (workspace-wide, StoriesPage overview)\n// ============================================================================\n\nexport function AiReviewQueue({ className }: { className?: string }) {\n const { workspaceId } = useTheCulturePost();\n const permissions = useSafePermissions();\n const { canRead, canReview } = resolveAiContextPermissions(permissions, workspaceId);\n\n if (!canRead) {\n return null;\n }\n\n return (\n <FeatureGate flag=\"theculturepost.ai-context\" defaultValue fallback={null}>\n <AiReviewQueueContent className={className} canReview={canReview} />\n </FeatureGate>\n );\n}\n\nfunction AiReviewQueueContent({\n className,\n canReview,\n}: {\n className?: string;\n canReview: boolean;\n}) {\n const runsQuery = useTcpAiContextRuns({ pagination: { limit: 50 } });\n const items = (runsQuery.data?.items ?? []).filter(isReviewableAiRun);\n\n if (runsQuery.isLoading) {\n return <LoadingView label=\"Loading AI review queue…\" />;\n }\n if (runsQuery.isError) {\n return (\n <ErrorView\n error={runsQuery.error}\n title=\"Could not load the AI review queue\"\n onRetry={() => runsQuery.refetch()}\n />\n );\n }\n if (items.length === 0) {\n return null;\n }\n\n return (\n <GlassCard treatment=\"plain\" className={`flex flex-col gap-3 p-5 sm:p-6 ${className ?? ''}`}>\n <h2 className=\"flex items-center gap-2 font-display text-xl font-semibold text-text-primary\">\n <Sparkles className=\"h-5 w-5 text-text-link\" aria-hidden=\"true\" /> AI review queue\n <span className=\"rounded-full bg-status-warning-bg-subtle px-2 py-0.5 text-xs font-medium text-status-warning-text\">\n {items.length} pending\n </span>\n </h2>\n <p className=\"text-sm text-text-secondary\">\n Generated answers awaiting an editorial decision, newest first. Approve or reject them here,\n or in place on the story or collection they belong to.\n </p>\n <div className=\"flex flex-col gap-3\">\n {items.slice(0, 5).map((run) => (\n <AiRunCard key={run.id} run={run} canReview={canReview} />\n ))}\n {items.length > 5 && (\n <p className=\"text-xs text-text-tertiary\">\n {items.length - 5} more pending — open the story or collection they belong to review\n them in place.\n </p>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkDA,IAAaE,IAAmD;CAC9D,oBAAoB;CACpB,sBAAsB;CACtB,4BAA4B;CAC5B,yBAAyB;CACzB,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBAAuB;CACvB,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAAgD;CACpD,oBAAoB;CACpB,sBACE;CACF,4BACE;CACF,yBACE;CACF,iBAAiB;CACjB,sBAAsB;CACtB,qBAAqB;CACrB,cAAc;CACd,iBAAiB;CACjB,iBAAiB;CACjB,uBACE;CACF,oBAAoB;CACpB,gBAAgB;AAClB,GAEMC,IAA4D;CAChE,UAAU;CACV,cAAc;CACd,cAAc;AAChB;AAoBA,SAAgBC,EAAwB,EACtC,SACA,iBACA,YACA,YACA,iBACA,kBACA,eAAY,IACZ,kBAC+B;CAC/B,IAAMC,IAAWC,EAAwB,GACnC,CAACC,GAAQC,KAAaC,QAAeP,EAAgBQ,EAAQ,GAC7D,CAACC,GAAKC,KAAUH,EAA6B,IAAI,GAEjDI,KAAS,MAAsB;EAMnC,AALKC,MACHN,EAAUN,EAAgBQ,EAAQ,GAClCE,EAAO,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AG,WAAU;IAA8B,UAAA;GAGxC,CAAA;GACH,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACGA,EAAM,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,MACtB,kBAACxD,GAAD;KAA6B;KAAgB;IAAY,GAAzCpB,EAAI,EAAqC,CAC1D,GACA4E,EAAM,SAAS,KACd,kBAAC,KAAD;KAAG,WAAU;KAAb,UAAA,CACGA,EAAM,SAAS,GAAE,mFAEjB;IAEF,CAAA,CAAA;;EACI;;AAEf"}
|
|
@@ -153,7 +153,7 @@ function R({ citation: n, compact: r = !1, footer: i }) {
|
|
|
153
153
|
href: n.url,
|
|
154
154
|
target: "_blank",
|
|
155
155
|
rel: "noreferrer noopener",
|
|
156
|
-
className: "inline-flex max-w-full items-center gap-1 text-xs font-medium text-
|
|
156
|
+
className: "inline-flex max-w-full items-center gap-1 text-xs font-medium text-text-link hover:underline",
|
|
157
157
|
children: [/* @__PURE__ */ O("span", {
|
|
158
158
|
className: "truncate",
|
|
159
159
|
children: r ? "View source" : n.url
|
|
@@ -227,15 +227,16 @@ function z() {
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
function B({ storyId: e, compact: t = !1, className: a }) {
|
|
230
|
-
let { data: s, isLoading: c, isError: l,
|
|
230
|
+
let { data: s, isLoading: c, isError: l, error: u, refetch: d } = i(e);
|
|
231
231
|
return c ? /* @__PURE__ */ O(r, {
|
|
232
232
|
label: "Loading citations…",
|
|
233
233
|
className: a
|
|
234
234
|
}) : l ? /* @__PURE__ */ O("div", {
|
|
235
235
|
className: a,
|
|
236
236
|
children: /* @__PURE__ */ O(n, {
|
|
237
|
+
error: u,
|
|
237
238
|
message: "We couldn't load citations.",
|
|
238
|
-
onRetry: () =>
|
|
239
|
+
onRetry: () => d()
|
|
239
240
|
})
|
|
240
241
|
}) : !s || s.length === 0 ? /* @__PURE__ */ O("div", {
|
|
241
242
|
className: a,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CitationList.js","names":["SOURCE_TYPE_ICON","GraduationCap","Landmark","Box","BookOpen","Mic","Newspaper","FileText","Globe","sourceTypeIcon","type","VERIFICATION_META","CheckCircle2","AlertCircle","XCircle","HelpCircle","VERIFICATIONS","SEGMENT_ACTIVE","VerificationSegments","cn","compact","className","meta","v","Icon","active","value","pending","onChange","CitationCard","verify","useTcpVerifyCitation","changeVerification","verification","citation","notify","formatEnumLabel","err","describeError","formatDate","createElement","StatusBadge","Quote","ExternalLink","SourceScanLink","ShieldCheck","Spinner","footer","MethodologyLegend","m","CitationList","citations","useTcpCitations","storyId","isLoading","LoadingView","isError","ErrorView","refetch","EmptyState","BookMarked"],"sources":["../../../src/theculturepost/components/CitationList.tsx"],"sourcesContent":["/**\n * CitationList — the verifiable sources that ground a story (tcp-05).\n * @module theculturepost/components\n *\n * Reads `tcpListCitations(storyId)`; each entry can be moved through its\n * verification state (`tcpVerifyCitation`) via a **segmented control** — the\n * archival-integrity control at the heart of a serious cultural publication.\n *\n * Each source shows a source-type icon, its bibliographic detail, an optional\n * excerpt + link, and (in the full variant) closes with a static methodology\n * legend. The claim-by-claim evidence trail (each claim in the body linked to\n * the citations that support it) lives on the standalone StoryCitationsPage,\n * which reuses {@link CitationCard} and {@link MethodologyLegend} from here.\n *\n * Two layouts, same data:\n * - default (full): roomy cards + labelled segments + methodology legend.\n * - `compact`: narrow-rail cards + icon-only segments, no legend.\n */\n\nimport {\n BookOpen,\n GraduationCap,\n Landmark,\n FileText,\n Globe,\n Newspaper,\n Mic,\n Box,\n ExternalLink,\n Quote,\n ShieldCheck,\n CheckCircle2,\n AlertCircle,\n XCircle,\n HelpCircle,\n BookMarked,\n type LucideIcon,\n} from 'lucide-react';\nimport { createElement, type ReactNode } from 'react';\nimport { Spinner, EmptyState } from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { SourceScanLink } from './SourceScanLink';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTcpCitations, useTcpVerifyCitation } from '../hooks';\nimport { cn } from '../utils/cn';\nimport { formatDate, formatEnumLabel } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { TcpCitation, TcpSourceType, TcpVerificationStatus } from '../types';\n\n// ---------------------------------------------------------------------------\n// Source-type + verification metadata (exported for reuse in the editorial table)\n// ---------------------------------------------------------------------------\n\n/** A distinct lucide motif per source type (icon, not hue — per the design rules). */\nexport const SOURCE_TYPE_ICON: Record<TcpSourceType, LucideIcon> = {\n ACADEMIC: GraduationCap,\n ARCHIVAL_RECORD: Landmark,\n ARTIFACT: Box,\n BOOK: BookOpen,\n INTERVIEW: Mic,\n PERIODICAL: Newspaper,\n PRIMARY_DOCUMENT: FileText,\n WEB: Globe,\n};\n\n/** Resolve a source-type's motif icon, falling back to a neutral document. */\nexport function sourceTypeIcon(type: TcpSourceType): LucideIcon {\n return SOURCE_TYPE_ICON[type] ?? FileText;\n}\n\ntype VerificationAccent = 'success' | 'warning' | 'destructive' | 'secondary';\n\ninterface VerificationMetaEntry {\n icon: LucideIcon;\n accent: VerificationAccent;\n label: string;\n /** Static, factual description of what the state means — shown in the legend. */\n blurb: string;\n}\n\n/** Ordered, tone-mapped metadata for each verification state. */\nexport const VERIFICATION_META: Record<TcpVerificationStatus, VerificationMetaEntry> = {\n CORROBORATED: {\n icon: CheckCircle2,\n accent: 'success',\n label: 'Corroborated',\n blurb: 'Strong agreement among reliable sources.',\n },\n DISPUTED: {\n icon: AlertCircle,\n accent: 'warning',\n label: 'Disputed',\n blurb: 'Conflicting or insufficient evidence.',\n },\n RETRACTED: {\n icon: XCircle,\n accent: 'destructive',\n label: 'Retracted',\n blurb: 'The source has since been withdrawn.',\n },\n UNVERIFIED: {\n icon: HelpCircle,\n accent: 'secondary',\n label: 'Unverified',\n blurb: 'Not yet reviewed by an editor.',\n },\n};\n\n/** The order the segmented control presents states in. */\nexport const VERIFICATIONS: TcpVerificationStatus[] = [\n 'CORROBORATED',\n 'DISPUTED',\n 'RETRACTED',\n 'UNVERIFIED',\n];\n\n/** Active-segment styling per accent — semantic tokens only. */\nconst SEGMENT_ACTIVE: Record<VerificationAccent, string> = {\n success: 'bg-status-success-bg-subtle text-status-success-text shadow-elevation-1',\n warning: 'bg-status-warning-bg-subtle text-status-warning-text shadow-elevation-1',\n destructive: 'bg-status-error-bg-subtle text-status-error-text shadow-elevation-1',\n secondary: 'bg-bg-sunken text-text-primary shadow-elevation-1',\n};\n\n// ---------------------------------------------------------------------------\n// Segmented verification control\n// ---------------------------------------------------------------------------\n\ninterface VerificationSegmentsProps {\n value: TcpVerificationStatus;\n onChange: (value: TcpVerificationStatus) => void;\n pending?: boolean;\n /** Icon-only segments (for the narrow reading rail). */\n compact?: boolean;\n className?: string;\n}\n\nfunction VerificationSegments({\n value,\n onChange,\n pending = false,\n compact = false,\n className,\n}: VerificationSegmentsProps) {\n return (\n <div\n role=\"radiogroup\"\n aria-label=\"Verification status\"\n className={cn(\n 'grid grid-cols-2 gap-1 rounded-xl border border-border-seam bg-bg-surface p-1',\n compact ? 'grid-cols-4' : 'sm:inline-grid sm:auto-cols-max sm:grid-flow-col',\n className\n )}\n >\n {VERIFICATIONS.map((v) => {\n const meta = VERIFICATION_META[v];\n const Icon = meta.icon;\n const active = v === value;\n return (\n <button\n key={v}\n type=\"button\"\n role=\"radio\"\n aria-checked={active}\n aria-label={meta.label}\n title={meta.label}\n disabled={pending}\n onClick={() => onChange(v)}\n className={cn(\n 'inline-flex min-h-9 items-center justify-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:opacity-60',\n active\n ? SEGMENT_ACTIVE[meta.accent]\n : 'text-text-tertiary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n <Icon className=\"h-3.5 w-3.5 shrink-0\" aria-hidden=\"true\" />\n <span className={compact ? 'sr-only' : 'hidden sm:inline'}>{meta.label}</span>\n </button>\n );\n })}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Citation row\n// ---------------------------------------------------------------------------\n\ninterface CitationCardProps {\n citation: TcpCitation;\n compact?: boolean;\n /** Extra controls rendered under the verification row (e.g. claim linking). */\n footer?: ReactNode;\n}\n\nexport function CitationCard({ citation, compact = false, footer }: CitationCardProps) {\n const verify = useTcpVerifyCitation();\n\n const changeVerification = async (verification: TcpVerificationStatus) => {\n if (verification === citation.verification) return;\n try {\n await verify.mutateAsync({ id: citation.id, verification });\n notify.success('Verification updated', formatEnumLabel(verification));\n } catch (err) {\n notify.error('Could not update verification', describeError(err));\n }\n };\n\n const meta = [citation.author, citation.publisher, formatDate(citation.publishedOn)]\n .filter((v) => v && v !== '—')\n .join(' · ');\n\n return (\n <li\n className={cn(\n 'rounded-2xl border border-border-seam bg-bg-surface transition-colors hover:border-border-strong',\n compact ? 'p-3.5' : 'p-4 sm:p-5'\n )}\n >\n <div className={cn('flex gap-3', compact ? 'items-start' : 'sm:gap-4')}>\n {/* Source-type motif tile */}\n <span\n className={cn(\n 'grid shrink-0 place-items-center rounded-xl bg-[var(--color-accent-soft)] text-text-primary',\n compact ? 'h-9 w-9' : 'h-12 w-12'\n )}\n aria-hidden=\"true\"\n >\n {createElement(sourceTypeIcon(citation.sourceType), {\n className: compact ? 'h-4 w-4' : 'h-6 w-6',\n })}\n </span>\n\n <div className=\"min-w-0 flex-1\">\n <div className=\"mb-1 flex flex-wrap items-center gap-1.5\">\n <StatusBadge\n status={citation.sourceType}\n icon={createElement(sourceTypeIcon(citation.sourceType), { className: 'h-3 w-3' })}\n />\n {compact && <StatusBadge status={citation.verification} />}\n </div>\n\n <p\n className={cn(\n 'font-display font-semibold leading-snug text-text-primary',\n compact ? 'text-sm' : 'text-base'\n )}\n >\n {citation.title}\n </p>\n {meta && <p className=\"mt-0.5 text-xs text-text-tertiary\">{meta}</p>}\n\n {citation.excerpt && !compact && (\n <blockquote className=\"mt-3 flex gap-2 rounded-lg bg-bg-sunken/60 px-3 py-2 text-sm text-text-secondary\">\n <Quote className=\"h-3.5 w-3.5 shrink-0 text-text-tertiary\" aria-hidden=\"true\" />\n <span>{citation.excerpt}</span>\n </blockquote>\n )}\n\n {citation.provenance && !compact && (\n <p className=\"mt-2 text-xs text-text-tertiary\">\n <span className=\"font-medium text-text-secondary\">Provenance:</span>{' '}\n {citation.provenance}\n </p>\n )}\n\n {(citation.url || citation.sourceFile) && (\n <div className=\"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1\">\n {citation.url && (\n <a\n href={citation.url}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n className=\"inline-flex max-w-full items-center gap-1 text-xs font-medium text-accent hover:underline\"\n >\n <span className=\"truncate\">{compact ? 'View source' : citation.url}</span>\n <ExternalLink className=\"h-3 w-3 shrink-0\" aria-hidden=\"true\" />\n </a>\n )}\n <SourceScanLink\n fileId={citation.sourceFile?.id}\n label={compact ? 'View scan' : 'View source scan'}\n />\n </div>\n )}\n </div>\n </div>\n\n {/* Verification control */}\n <div\n className={cn(\n 'mt-3 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-border-seam pt-3',\n compact ? '' : 'sm:justify-between'\n )}\n >\n <span className=\"inline-flex items-center gap-1.5 text-xs font-medium text-text-secondary\">\n <ShieldCheck className=\"h-3.5 w-3.5 text-text-tertiary\" aria-hidden=\"true\" />\n Verification\n {verify.isPending && <Spinner size=\"sm\" />}\n </span>\n <VerificationSegments\n value={citation.verification}\n onChange={changeVerification}\n pending={verify.isPending}\n compact={compact}\n />\n </div>\n {footer}\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Methodology legend (static — no fabricated data)\n// ---------------------------------------------------------------------------\n\nexport function MethodologyLegend() {\n return (\n <div className=\"mt-4 rounded-2xl border border-border-seam bg-bg-sunken/50 p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <span\n className=\"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[var(--color-accent-soft)] text-text-primary\"\n aria-hidden=\"true\"\n >\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <p className=\"text-sm text-text-secondary\">\n Every source is evaluated for accuracy, relevance, and cultural sensitivity through a\n transparent, multi-step review by editors and subject-area contributors.\n </p>\n </div>\n <dl className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n {VERIFICATIONS.map((v) => {\n const m = VERIFICATION_META[v];\n const Icon = m.icon;\n return (\n <div key={v} className=\"flex items-start gap-2\">\n <Icon\n className={cn(\n 'mt-0.5 h-4 w-4 shrink-0',\n m.accent === 'success' && 'text-status-success-text',\n m.accent === 'warning' && 'text-status-warning-text',\n m.accent === 'destructive' && 'text-status-error-text',\n m.accent === 'secondary' && 'text-text-tertiary'\n )}\n aria-hidden=\"true\"\n />\n <div>\n <dt className=\"text-xs font-semibold text-text-primary\">{m.label}</dt>\n <dd className=\"mt-0.5 text-xs text-text-tertiary\">{m.blurb}</dd>\n </div>\n </div>\n );\n })}\n </dl>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// CitationList\n// ---------------------------------------------------------------------------\n\ninterface CitationListProps {\n storyId: string;\n /** Narrow reading-rail rendering: smaller cards, icon-only segments, no legend. */\n compact?: boolean;\n className?: string;\n}\n\nexport function CitationList({ storyId, compact = false, className }: CitationListProps) {\n const { data: citations, isLoading, isError, refetch } = useTcpCitations(storyId);\n\n if (isLoading) return <LoadingView label=\"Loading citations…\" className={className} />;\n if (isError)\n return (\n <div className={className}>\n <ErrorView message=\"We couldn't load citations.\" onRetry={() => refetch()} />\n </div>\n );\n\n if (!citations || citations.length === 0) {\n return (\n <div className={className}>\n <EmptyState\n size=\"panel\"\n icon={<BookMarked className=\"h-9 w-9\" />}\n title=\"No citations yet\"\n description=\"Add verifiable sources to ground this story in the record.\"\n />\n </div>\n );\n }\n\n return (\n <div className={className}>\n <ul className={cn('flex flex-col', compact ? 'gap-3' : 'gap-3 sm:gap-4')}>\n {citations.map((citation) => (\n <CitationCard key={citation.id} citation={citation} compact={compact} />\n ))}\n </ul>\n {!compact && <MethodologyLegend />}\n </div>\n );\n}\n"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,WAAU,UAAW,CAAA;GACvC,OAAM;GACN,aAAY;EACb,CAAA;CACE,CAAA,IAKP,kBAAC,OAAD;EAAgB;EAAhB,UAAA,CACE,kBAAC,MAAD;GAAI,WAAWzC,EAAG,iBAAiBC,IAAU,UAAU,gBAAgB;GACpE,UAAA+B,EAAU,KAAK,MACd,kBAACtB,GAAD;IAA0C;IAAmB;GAAU,GAApDK,EAAS,EAA2C,CACxE;EACC,CAAA,GACH,CAACd,KAAW,kBAAC4B,GAAD,CAAoB,CAAA,CAC9B;;AAET"}
|
|
1
|
+
{"version":3,"file":"CitationList.js","names":["SOURCE_TYPE_ICON","GraduationCap","Landmark","Box","BookOpen","Mic","Newspaper","FileText","Globe","sourceTypeIcon","type","VERIFICATION_META","CheckCircle2","AlertCircle","XCircle","HelpCircle","VERIFICATIONS","SEGMENT_ACTIVE","VerificationSegments","cn","compact","className","meta","v","Icon","active","value","pending","onChange","CitationCard","verify","useTcpVerifyCitation","changeVerification","verification","citation","notify","formatEnumLabel","err","describeError","formatDate","createElement","StatusBadge","Quote","ExternalLink","SourceScanLink","ShieldCheck","Spinner","footer","MethodologyLegend","m","CitationList","citations","useTcpCitations","storyId","isLoading","LoadingView","isError","ErrorView","refetch","EmptyState","BookMarked"],"sources":["../../../src/theculturepost/components/CitationList.tsx"],"sourcesContent":["/**\n * CitationList — the verifiable sources that ground a story (tcp-05).\n * @module theculturepost/components\n *\n * Reads `tcpListCitations(storyId)`; each entry can be moved through its\n * verification state (`tcpVerifyCitation`) via a **segmented control** — the\n * archival-integrity control at the heart of a serious cultural publication.\n *\n * Each source shows a source-type icon, its bibliographic detail, an optional\n * excerpt + link, and (in the full variant) closes with a static methodology\n * legend. The claim-by-claim evidence trail (each claim in the body linked to\n * the citations that support it) lives on the standalone StoryCitationsPage,\n * which reuses {@link CitationCard} and {@link MethodologyLegend} from here.\n *\n * Two layouts, same data:\n * - default (full): roomy cards + labelled segments + methodology legend.\n * - `compact`: narrow-rail cards + icon-only segments, no legend.\n */\n\nimport {\n BookOpen,\n GraduationCap,\n Landmark,\n FileText,\n Globe,\n Newspaper,\n Mic,\n Box,\n ExternalLink,\n Quote,\n ShieldCheck,\n CheckCircle2,\n AlertCircle,\n XCircle,\n HelpCircle,\n BookMarked,\n type LucideIcon,\n} from 'lucide-react';\nimport { createElement, type ReactNode } from 'react';\nimport { Spinner, EmptyState } from '@burdenoff/fe-libs/ui';\nimport { StatusBadge } from './StatusBadge';\nimport { SourceScanLink } from './SourceScanLink';\nimport { LoadingView, ErrorView } from './StateViews';\nimport { useTcpCitations, useTcpVerifyCitation } from '../hooks';\nimport { cn } from '../utils/cn';\nimport { formatDate, formatEnumLabel } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { TcpCitation, TcpSourceType, TcpVerificationStatus } from '../types';\n\n// ---------------------------------------------------------------------------\n// Source-type + verification metadata (exported for reuse in the editorial table)\n// ---------------------------------------------------------------------------\n\n/** A distinct lucide motif per source type (icon, not hue — per the design rules). */\nexport const SOURCE_TYPE_ICON: Record<TcpSourceType, LucideIcon> = {\n ACADEMIC: GraduationCap,\n ARCHIVAL_RECORD: Landmark,\n ARTIFACT: Box,\n BOOK: BookOpen,\n INTERVIEW: Mic,\n PERIODICAL: Newspaper,\n PRIMARY_DOCUMENT: FileText,\n WEB: Globe,\n};\n\n/** Resolve a source-type's motif icon, falling back to a neutral document. */\nexport function sourceTypeIcon(type: TcpSourceType): LucideIcon {\n return SOURCE_TYPE_ICON[type] ?? FileText;\n}\n\ntype VerificationAccent = 'success' | 'warning' | 'destructive' | 'secondary';\n\ninterface VerificationMetaEntry {\n icon: LucideIcon;\n accent: VerificationAccent;\n label: string;\n /** Static, factual description of what the state means — shown in the legend. */\n blurb: string;\n}\n\n/** Ordered, tone-mapped metadata for each verification state. */\nexport const VERIFICATION_META: Record<TcpVerificationStatus, VerificationMetaEntry> = {\n CORROBORATED: {\n icon: CheckCircle2,\n accent: 'success',\n label: 'Corroborated',\n blurb: 'Strong agreement among reliable sources.',\n },\n DISPUTED: {\n icon: AlertCircle,\n accent: 'warning',\n label: 'Disputed',\n blurb: 'Conflicting or insufficient evidence.',\n },\n RETRACTED: {\n icon: XCircle,\n accent: 'destructive',\n label: 'Retracted',\n blurb: 'The source has since been withdrawn.',\n },\n UNVERIFIED: {\n icon: HelpCircle,\n accent: 'secondary',\n label: 'Unverified',\n blurb: 'Not yet reviewed by an editor.',\n },\n};\n\n/** The order the segmented control presents states in. */\nexport const VERIFICATIONS: TcpVerificationStatus[] = [\n 'CORROBORATED',\n 'DISPUTED',\n 'RETRACTED',\n 'UNVERIFIED',\n];\n\n/** Active-segment styling per accent — semantic tokens only. */\nconst SEGMENT_ACTIVE: Record<VerificationAccent, string> = {\n success: 'bg-status-success-bg-subtle text-status-success-text shadow-elevation-1',\n warning: 'bg-status-warning-bg-subtle text-status-warning-text shadow-elevation-1',\n destructive: 'bg-status-error-bg-subtle text-status-error-text shadow-elevation-1',\n secondary: 'bg-bg-sunken text-text-primary shadow-elevation-1',\n};\n\n// ---------------------------------------------------------------------------\n// Segmented verification control\n// ---------------------------------------------------------------------------\n\ninterface VerificationSegmentsProps {\n value: TcpVerificationStatus;\n onChange: (value: TcpVerificationStatus) => void;\n pending?: boolean;\n /** Icon-only segments (for the narrow reading rail). */\n compact?: boolean;\n className?: string;\n}\n\nfunction VerificationSegments({\n value,\n onChange,\n pending = false,\n compact = false,\n className,\n}: VerificationSegmentsProps) {\n return (\n <div\n role=\"radiogroup\"\n aria-label=\"Verification status\"\n className={cn(\n 'grid grid-cols-2 gap-1 rounded-xl border border-border-seam bg-bg-surface p-1',\n compact ? 'grid-cols-4' : 'sm:inline-grid sm:auto-cols-max sm:grid-flow-col',\n className\n )}\n >\n {VERIFICATIONS.map((v) => {\n const meta = VERIFICATION_META[v];\n const Icon = meta.icon;\n const active = v === value;\n return (\n <button\n key={v}\n type=\"button\"\n role=\"radio\"\n aria-checked={active}\n aria-label={meta.label}\n title={meta.label}\n disabled={pending}\n onClick={() => onChange(v)}\n className={cn(\n 'inline-flex min-h-9 items-center justify-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors disabled:opacity-60',\n active\n ? SEGMENT_ACTIVE[meta.accent]\n : 'text-text-tertiary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n <Icon className=\"h-3.5 w-3.5 shrink-0\" aria-hidden=\"true\" />\n <span className={compact ? 'sr-only' : 'hidden sm:inline'}>{meta.label}</span>\n </button>\n );\n })}\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Citation row\n// ---------------------------------------------------------------------------\n\ninterface CitationCardProps {\n citation: TcpCitation;\n compact?: boolean;\n /** Extra controls rendered under the verification row (e.g. claim linking). */\n footer?: ReactNode;\n}\n\nexport function CitationCard({ citation, compact = false, footer }: CitationCardProps) {\n const verify = useTcpVerifyCitation();\n\n const changeVerification = async (verification: TcpVerificationStatus) => {\n if (verification === citation.verification) return;\n try {\n await verify.mutateAsync({ id: citation.id, verification });\n notify.success('Verification updated', formatEnumLabel(verification));\n } catch (err) {\n notify.error('Could not update verification', describeError(err));\n }\n };\n\n const meta = [citation.author, citation.publisher, formatDate(citation.publishedOn)]\n .filter((v) => v && v !== '—')\n .join(' · ');\n\n return (\n <li\n className={cn(\n 'rounded-2xl border border-border-seam bg-bg-surface transition-colors hover:border-border-strong',\n compact ? 'p-3.5' : 'p-4 sm:p-5'\n )}\n >\n <div className={cn('flex gap-3', compact ? 'items-start' : 'sm:gap-4')}>\n {/* Source-type motif tile */}\n <span\n className={cn(\n 'grid shrink-0 place-items-center rounded-xl bg-[var(--color-accent-soft)] text-text-primary',\n compact ? 'h-9 w-9' : 'h-12 w-12'\n )}\n aria-hidden=\"true\"\n >\n {createElement(sourceTypeIcon(citation.sourceType), {\n className: compact ? 'h-4 w-4' : 'h-6 w-6',\n })}\n </span>\n\n <div className=\"min-w-0 flex-1\">\n <div className=\"mb-1 flex flex-wrap items-center gap-1.5\">\n <StatusBadge\n status={citation.sourceType}\n icon={createElement(sourceTypeIcon(citation.sourceType), { className: 'h-3 w-3' })}\n />\n {compact && <StatusBadge status={citation.verification} />}\n </div>\n\n <p\n className={cn(\n 'font-display font-semibold leading-snug text-text-primary',\n compact ? 'text-sm' : 'text-base'\n )}\n >\n {citation.title}\n </p>\n {meta && <p className=\"mt-0.5 text-xs text-text-tertiary\">{meta}</p>}\n\n {citation.excerpt && !compact && (\n <blockquote className=\"mt-3 flex gap-2 rounded-lg bg-bg-sunken/60 px-3 py-2 text-sm text-text-secondary\">\n <Quote className=\"h-3.5 w-3.5 shrink-0 text-text-tertiary\" aria-hidden=\"true\" />\n <span>{citation.excerpt}</span>\n </blockquote>\n )}\n\n {citation.provenance && !compact && (\n <p className=\"mt-2 text-xs text-text-tertiary\">\n <span className=\"font-medium text-text-secondary\">Provenance:</span>{' '}\n {citation.provenance}\n </p>\n )}\n\n {(citation.url || citation.sourceFile) && (\n <div className=\"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1\">\n {citation.url && (\n <a\n href={citation.url}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n className=\"inline-flex max-w-full items-center gap-1 text-xs font-medium text-text-link hover:underline\"\n >\n <span className=\"truncate\">{compact ? 'View source' : citation.url}</span>\n <ExternalLink className=\"h-3 w-3 shrink-0\" aria-hidden=\"true\" />\n </a>\n )}\n <SourceScanLink\n fileId={citation.sourceFile?.id}\n label={compact ? 'View scan' : 'View source scan'}\n />\n </div>\n )}\n </div>\n </div>\n\n {/* Verification control */}\n <div\n className={cn(\n 'mt-3 flex flex-wrap items-center gap-x-3 gap-y-2 border-t border-border-seam pt-3',\n compact ? '' : 'sm:justify-between'\n )}\n >\n <span className=\"inline-flex items-center gap-1.5 text-xs font-medium text-text-secondary\">\n <ShieldCheck className=\"h-3.5 w-3.5 text-text-tertiary\" aria-hidden=\"true\" />\n Verification\n {verify.isPending && <Spinner size=\"sm\" />}\n </span>\n <VerificationSegments\n value={citation.verification}\n onChange={changeVerification}\n pending={verify.isPending}\n compact={compact}\n />\n </div>\n {footer}\n </li>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Methodology legend (static — no fabricated data)\n// ---------------------------------------------------------------------------\n\nexport function MethodologyLegend() {\n return (\n <div className=\"mt-4 rounded-2xl border border-border-seam bg-bg-sunken/50 p-4 sm:p-5\">\n <div className=\"flex items-start gap-3\">\n <span\n className=\"grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-[var(--color-accent-soft)] text-text-primary\"\n aria-hidden=\"true\"\n >\n <ShieldCheck className=\"h-5 w-5\" />\n </span>\n <p className=\"text-sm text-text-secondary\">\n Every source is evaluated for accuracy, relevance, and cultural sensitivity through a\n transparent, multi-step review by editors and subject-area contributors.\n </p>\n </div>\n <dl className=\"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4\">\n {VERIFICATIONS.map((v) => {\n const m = VERIFICATION_META[v];\n const Icon = m.icon;\n return (\n <div key={v} className=\"flex items-start gap-2\">\n <Icon\n className={cn(\n 'mt-0.5 h-4 w-4 shrink-0',\n m.accent === 'success' && 'text-status-success-text',\n m.accent === 'warning' && 'text-status-warning-text',\n m.accent === 'destructive' && 'text-status-error-text',\n m.accent === 'secondary' && 'text-text-tertiary'\n )}\n aria-hidden=\"true\"\n />\n <div>\n <dt className=\"text-xs font-semibold text-text-primary\">{m.label}</dt>\n <dd className=\"mt-0.5 text-xs text-text-tertiary\">{m.blurb}</dd>\n </div>\n </div>\n );\n })}\n </dl>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// CitationList\n// ---------------------------------------------------------------------------\n\ninterface CitationListProps {\n storyId: string;\n /** Narrow reading-rail rendering: smaller cards, icon-only segments, no legend. */\n compact?: boolean;\n className?: string;\n}\n\nexport function CitationList({ storyId, compact = false, className }: CitationListProps) {\n const { data: citations, isLoading, isError, error, refetch } = useTcpCitations(storyId);\n\n if (isLoading) return <LoadingView label=\"Loading citations…\" className={className} />;\n if (isError)\n return (\n <div className={className}>\n <ErrorView error={error} message=\"We couldn't load citations.\" onRetry={() => refetch()} />\n </div>\n );\n\n if (!citations || citations.length === 0) {\n return (\n <div className={className}>\n <EmptyState\n size=\"panel\"\n icon={<BookMarked className=\"h-9 w-9\" />}\n title=\"No citations yet\"\n description=\"Add verifiable sources to ground this story in the record.\"\n />\n </div>\n );\n }\n\n return (\n <div className={className}>\n <ul className={cn('flex flex-col', compact ? 'gap-3' : 'gap-3 sm:gap-4')}>\n {citations.map((citation) => (\n <CitationCard key={citation.id} citation={citation} compact={compact} />\n ))}\n </ul>\n {!compact && <MethodologyLegend />}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAsDA,IAAaA,IAAsD;CACjE,UAAUC;CACV,iBAAiBC;CACjB,UAAUC;CACV,MAAMC;CACN,WAAWC;CACX,YAAYC;CACZ,kBAAkBC;CAClB,KAAKC;AACP;AAGA,SAAgBC,EAAe,GAAiC;CAC9D,OAAOT,EAAiBU,MAASH;AACnC;AAaA,IAAaI,IAA0E;CACrF,cAAc;EACZ,MAAMC;EACN,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,UAAU;EACR,MAAMC;EACN,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,WAAW;EACT,MAAMC;EACN,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,YAAY;EACV,MAAMC;EACN,QAAQ;EACR,OAAO;EACP,OAAO;CACT;AACF,GAGaC,IAAyC;CACpD;CACA;CACA;CACA;AACF,GAGMC,IAAqD;CACzD,SAAS;CACT,SAAS;CACT,aAAa;CACb,WAAW;AACb;AAeA,SAASC,EAAqB,EAC5B,UACA,aACA,aAAU,IACV,aAAU,IACV,gBAC4B;CAC5B,OACE,kBAAC,OAAD;EACE,MAAK;EACL,cAAW;EACX,WAAWC,EACT,iFACAC,IAAU,gBAAgB,oDAC1BC,CACF;EAEC,UAAAL,EAAc,KAAK,MAAM;GACxB,IAAMM,IAAOX,EAAkBY,IACzBC,IAAOF,EAAK,MACZG,IAASF,MAAMG;GACrB,O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AM,EAAE,MAAMC,GAAW,cAAW,YAAS,UAAO,eAAYC,EAAgBC,CAAO;CAuBvF,OArBIC,IAAkB,kBAACC,GAAD;EAAa,OAAM;EAAgC;CAAY,CAAA,IACjFC,IAEA,kBAAC,OAAD;EAAgB;EACd,UAAA,kBAACC,GAAD;GAAkB;GAAO,SAAQ;GAA8B,eAAeC,EAAQ;EAAI,CAAA;CACvF,CAAA,IAGL,CAACP,KAAaA,EAAU,WAAW,IAEnC,kBAAC,OAAD;EAAgB;EACd,UAAA,kBAACQ,GAAD;GACE,MAAK;GACL,MAAM,kBAACC,GAAD,EAAY,WAAU,UAAW,CAAA;GACvC,OAAM;GACN,aAAY;EACb,CAAA;CACE,CAAA,IAKP,kBAAC,OAAD;EAAgB;EAAhB,UAAA,CACE,kBAAC,MAAD;GAAI,WAAWzC,EAAG,iBAAiBC,IAAU,UAAU,gBAAgB;GACpE,UAAA+B,EAAU,KAAK,MACd,kBAACtB,GAAD;IAA0C;IAAmB;GAAU,GAApDK,EAAS,EAA2C,CACxE;EACC,CAAA,GACH,CAACd,KAAW,kBAAC4B,GAAD,CAAoB,CAAA,CAC9B;;AAET"}
|
|
@@ -28,7 +28,7 @@ function s({ className: s, compact: c = !1 }) {
|
|
|
28
28
|
id: u,
|
|
29
29
|
className: "flex items-center gap-2 text-sm font-semibold text-text-primary",
|
|
30
30
|
children: [/* @__PURE__ */ i(r, {
|
|
31
|
-
className: "h-4 w-4 text-
|
|
31
|
+
className: "h-4 w-4 text-text-link",
|
|
32
32
|
"aria-hidden": "true"
|
|
33
33
|
}), l("norms.title", "Community norms")]
|
|
34
34
|
}), /* @__PURE__ */ i("ul", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommunityNorms.js","names":["COMMUNITY_NORMS","CommunityNorms","tr","useTr","titleId","useId","cn","compact","className","HeartHandshake","norm"],"sources":["../../../src/theculturepost/components/CommunityNorms.tsx"],"sourcesContent":["/**\n * CommunityNorms — the community norms, shown up front wherever people\n * start or join a conversation (discussions list, discussion detail, and the\n * open-discussion dialog).\n * @module theculturepost/components\n *\n * Product-wide norms from i18n keys (`norms.*`); workspace-editable norms are\n * a post-launch enhancement. Semantic tokens only.\n */\n\nimport { useId } from 'react';\nimport { HeartHandshake } from 'lucide-react';\nimport { useTr } from '../hooks';\nimport { cn } from '../utils/cn';\n\nexport interface CommunityNorm {\n key: string;\n fallback: string;\n}\n\n/** The norms, in display order. Exported so tests can pin the i18n keys. */\nexport const COMMUNITY_NORMS: readonly CommunityNorm[] = [\n {\n key: 'norms.respect',\n fallback: 'Treat every tradition, faith and community with respect.',\n },\n {\n key: 'norms.ownVoice',\n fallback: 'Speak from your own experience; do not speak for others.',\n },\n {\n key: 'norms.ideas',\n fallback: 'Challenge ideas, never people, and cite sources where you can.',\n },\n];\n\ninterface CommunityNormsProps {\n className?: string;\n /** Tighter spacing for dialogs and list headers. */\n compact?: boolean;\n}\n\nexport function CommunityNorms({ className, compact = false }: CommunityNormsProps) {\n const tr = useTr();\n const titleId = useId();\n return (\n <section\n aria-labelledby={titleId}\n className={cn(\n 'rounded-xl border border-border-seam bg-[var(--color-accent-soft)]',\n compact ? 'p-3' : 'p-4',\n className\n )}\n >\n <h2 id={titleId} className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <HeartHandshake className=\"h-4 w-4 text-
|
|
1
|
+
{"version":3,"file":"CommunityNorms.js","names":["COMMUNITY_NORMS","CommunityNorms","tr","useTr","titleId","useId","cn","compact","className","HeartHandshake","norm"],"sources":["../../../src/theculturepost/components/CommunityNorms.tsx"],"sourcesContent":["/**\n * CommunityNorms — the community norms, shown up front wherever people\n * start or join a conversation (discussions list, discussion detail, and the\n * open-discussion dialog).\n * @module theculturepost/components\n *\n * Product-wide norms from i18n keys (`norms.*`); workspace-editable norms are\n * a post-launch enhancement. Semantic tokens only.\n */\n\nimport { useId } from 'react';\nimport { HeartHandshake } from 'lucide-react';\nimport { useTr } from '../hooks';\nimport { cn } from '../utils/cn';\n\nexport interface CommunityNorm {\n key: string;\n fallback: string;\n}\n\n/** The norms, in display order. Exported so tests can pin the i18n keys. */\nexport const COMMUNITY_NORMS: readonly CommunityNorm[] = [\n {\n key: 'norms.respect',\n fallback: 'Treat every tradition, faith and community with respect.',\n },\n {\n key: 'norms.ownVoice',\n fallback: 'Speak from your own experience; do not speak for others.',\n },\n {\n key: 'norms.ideas',\n fallback: 'Challenge ideas, never people, and cite sources where you can.',\n },\n];\n\ninterface CommunityNormsProps {\n className?: string;\n /** Tighter spacing for dialogs and list headers. */\n compact?: boolean;\n}\n\nexport function CommunityNorms({ className, compact = false }: CommunityNormsProps) {\n const tr = useTr();\n const titleId = useId();\n return (\n <section\n aria-labelledby={titleId}\n className={cn(\n 'rounded-xl border border-border-seam bg-[var(--color-accent-soft)]',\n compact ? 'p-3' : 'p-4',\n className\n )}\n >\n <h2 id={titleId} className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n <HeartHandshake className=\"h-4 w-4 text-text-link\" aria-hidden=\"true\" />\n {tr('norms.title', 'Community norms')}\n </h2>\n <ul className=\"mt-2 flex list-disc flex-col gap-1 ps-5 text-sm text-text-secondary\">\n {COMMUNITY_NORMS.map((norm) => (\n <li key={norm.key}>{tr(norm.key, norm.fallback)}</li>\n ))}\n </ul>\n </section>\n );\n}\n"],"mappings":";;;;;;;AAqBA,IAAaA,IAA4C;CACvD;EACE,KAAK;EACL,UAAU;CACZ;CACA;EACE,KAAK;EACL,UAAU;CACZ;CACA;EACE,KAAK;EACL,UAAU;CACZ;AACF;AAQA,SAAgBC,EAAe,EAAE,cAAW,aAAU,MAA8B;CAClF,IAAMC,IAAKC,EAAM,GACXC,IAAUC,EAAM;CACtB,OACE,kBAAC,WAAD;EACE,mBAAiBD;EACjB,WAAWE,EACT,sEACAC,IAAU,QAAQ,OAClBC,CACF;EANF,UAAA,CAQE,kBAAC,MAAD;GAAI,IAAIJ;GAAS,WAAU;GAA3B,UAAA,CACE,kBAACK,GAAD;IAAgB,WAAU;IAAyB,eAAY;GAAQ,CAAA,GACtEP,EAAG,eAAe,iBAAiB,CAClC;EACJ,CAAA,GAAA,kBAAC,MAAD;GAAI,WAAU;GACX,UAAAF,EAAgB,KAAK,MACpB,kBAAC,MAAD,EAAA,UAAoBE,EAAGQ,EAAK,KAAKA,EAAK,QAAQ,EAAM,GAA3CA,EAAK,GAAsC,CACrD;EACC,CAAA,CACG;;AAEb"}
|
|
@@ -127,7 +127,7 @@ function ae({ coverFileId: e, onUploaded: r, onCleared: i }) {
|
|
|
127
127
|
className: "flex flex-col items-center justify-center gap-3 sm:flex-row",
|
|
128
128
|
children: [
|
|
129
129
|
/* @__PURE__ */ v(h, {
|
|
130
|
-
className: "h-8 w-8 text-
|
|
130
|
+
className: "h-8 w-8 text-text-link",
|
|
131
131
|
"aria-hidden": "true"
|
|
132
132
|
}),
|
|
133
133
|
/* @__PURE__ */ v("p", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateStoryDialog.js","names":["_Fragment","Fragment$1","FORMATS","SUMMARY_MAX","COVER_MAX_MB","CoverDropzone","inputRef","useRef","uploading","setUploading","useState","dragActive","setDragActive","previewUrl","setPreviewUrl","fileName","setFileName","handleFile","file","uploaded","uploadImageToFiles","FILE_FOLDERS","onUploaded","notify","err","describeError","onInputChange","event","onDrop","clear","onCleared","hiddenInput","X","coverFileId","FileCheck2","cn","Loader2","UploadCloud","Button","CreateStoryDialog","createStory","useTcpCreateStory","topicsQuery","useTcpTopics","title","setTitle","slug","setSlug","slugTouched","setSlugTouched","summary","setSummary","body","setBody","format","setFormat","pickedTopic","setPickedTopic","topicId","languages","setLanguages","tags","setTags","readingMins","setReadingMins","setCoverFileId","error","setError","resetNonce","setResetNonce","effectiveSlug","slugify","reset","n","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Label","Input","CheckCircle2","Select","v","SelectTrigger","SelectValue","SelectContent","SelectItem","f","formatEnumLabel","topic","Textarea","FramingPrompts","TagInput","ResponsiveDialogFooter","onOpenChange","created","onCreated","message"],"sources":["../../../src/theculturepost/components/CreateStoryDialog.tsx"],"sourcesContent":["/**\n * CreateStoryDialog — draft a new story.\n * @module theculturepost/components\n *\n * Writes `tcpCreateStory`. A wide, two-column composer that mirrors the editorial\n * \"Draft a story\" surface: a real drag-and-drop cover dropzone (uploads to\n * wspace-files-svc and keeps the returned `coverFileId`), a title with an\n * auto-derived URL slug + uniqueness hint, char counters on summary/body, and\n * chip multiselects for languages/tags. New stories begin at the start of the\n * editorial lifecycle (IDEA/DRAFT on the svc). Every field maps to a real\n * `TcpCreateStoryInput` field — no bookmarks, no fabricated metadata.\n */\n\nimport { useRef, useState, type ChangeEvent, type DragEvent } from 'react';\nimport { UploadCloud, Loader2, X, CheckCircle2, FileCheck2 } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { FramingPrompts } from './FramingPrompts';\nimport { TagInput } from './TagInput';\nimport { cn } from '../utils/cn';\nimport { useTcpCreateStory, useTcpTopics, uploadImageToFiles, FILE_FOLDERS } from '../hooks';\nimport { slugify } from '../utils/slug';\nimport { formatEnumLabel } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { TcpStory, TcpStoryFormat } from '../types';\n\nconst FORMATS: TcpStoryFormat[] = [\n 'ARTICLE',\n 'ESSAY',\n 'EXPLAINER',\n 'ORAL_HISTORY',\n 'PHOTO_STORY',\n 'TIMELINE',\n];\n\nconst SUMMARY_MAX = 200;\nconst COVER_MAX_MB = 25;\n\n// ---------------------------------------------------------------------------\n// Cover dropzone (real drag-and-drop → wspace-files-svc)\n// ---------------------------------------------------------------------------\n\ninterface CoverDropzoneProps {\n coverFileId: string | null;\n onUploaded: (fileId: string) => void;\n onCleared: () => void;\n}\n\nfunction CoverDropzone({ coverFileId, onUploaded, onCleared }: CoverDropzoneProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const [uploading, setUploading] = useState(false);\n const [dragActive, setDragActive] = useState(false);\n const [previewUrl, setPreviewUrl] = useState<string | null>(null);\n const [fileName, setFileName] = useState<string | null>(null);\n\n const handleFile = async (file: File) => {\n if (!file.type.startsWith('image/')) {\n notify.error('Unsupported file', 'Please choose an image (JPG or PNG).');\n return;\n }\n if (file.size > COVER_MAX_MB * 1024 * 1024) {\n notify.error('File too large', `Please choose an image under ${COVER_MAX_MB} MB.`);\n return;\n }\n setUploading(true);\n try {\n const uploaded = await uploadImageToFiles(file, FILE_FOLDERS.covers);\n setPreviewUrl(uploaded.url);\n setFileName(uploaded.name);\n onUploaded(uploaded.id);\n notify.success('Cover uploaded', uploaded.name);\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n const onInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n event.target.value = '';\n if (file) void handleFile(file);\n };\n\n const onDrop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragActive(false);\n if (uploading) return;\n const file = event.dataTransfer.files?.[0];\n if (file) void handleFile(file);\n };\n\n const clear = () => {\n setPreviewUrl(null);\n setFileName(null);\n onCleared();\n };\n\n const hiddenInput = (\n <input\n ref={inputRef}\n type=\"file\"\n accept=\"image/*\"\n className=\"sr-only\"\n onChange={onInputChange}\n disabled={uploading}\n aria-label=\"Upload cover image\"\n />\n );\n\n // Uploaded image preview\n if (previewUrl) {\n return (\n <div className=\"relative overflow-hidden rounded-2xl border border-border-seam\">\n {hiddenInput}\n <img src={previewUrl} alt=\"Cover preview\" className=\"max-h-52 w-full object-cover\" />\n <div className=\"absolute end-2 top-2 flex gap-1.5\">\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n className=\"rounded-full bg-bg-canvas/85 px-2.5 py-1 text-xs font-medium text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n Replace\n </button>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"rounded-full bg-bg-canvas/85 p-1.5 text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n );\n }\n\n // Cover set but no local preview (defensive)\n if (coverFileId) {\n return (\n <div className=\"flex items-center justify-between gap-2 rounded-2xl border border-border-seam bg-bg-surface px-3 py-2.5 text-sm\">\n {hiddenInput}\n <span className=\"inline-flex min-w-0 items-center gap-2 text-text-primary\">\n <FileCheck2 className=\"h-4 w-4 shrink-0 text-status-success-text\" aria-hidden=\"true\" />\n <span className=\"truncate\">{fileName ?? 'Cover selected'}</span>\n </span>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"text-text-tertiary hover:text-text-primary\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n );\n }\n\n // Empty dropzone\n return (\n <div\n onDragOver={(event) => {\n event.preventDefault();\n if (!uploading) setDragActive(true);\n }}\n onDragLeave={(event) => {\n event.preventDefault();\n setDragActive(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'rounded-2xl border-2 border-dashed px-4 py-6 text-center transition-colors',\n dragActive\n ? 'border-accent bg-[var(--color-accent-soft)]'\n : 'border-border-seam bg-bg-sunken/40'\n )}\n >\n {hiddenInput}\n {uploading ? (\n <div className=\"flex items-center justify-center gap-2 text-sm text-text-secondary\">\n <Loader2 className=\"h-5 w-5 animate-spin\" aria-hidden=\"true\" /> Uploading cover…\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center gap-3 sm:flex-row\">\n <UploadCloud className=\"h-8 w-8 text-accent\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">Drag and drop an image here, or</p>\n <Button type=\"button\" size=\"sm\" onClick={() => inputRef.current?.click()}>\n Upload cover\n </Button>\n </div>\n )}\n <p className=\"mt-3 text-xs text-text-tertiary\">\n Recommended: 16:9 ratio, min 1200×675px. JPG or PNG, up to {COVER_MAX_MB} MB.\n </p>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Dialog\n// ---------------------------------------------------------------------------\n\ninterface CreateStoryDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Pre-select a topic (e.g. from a topic detail page). */\n topicId?: string;\n onCreated?: (story: TcpStory) => void;\n}\n\nexport function CreateStoryDialog({\n open,\n onOpenChange,\n topicId,\n onCreated,\n}: CreateStoryDialogProps) {\n const createStory = useTcpCreateStory();\n const topicsQuery = useTcpTopics({ pagination: { limit: 100 } });\n\n const [title, setTitle] = useState('');\n const [slug, setSlug] = useState('');\n const [slugTouched, setSlugTouched] = useState(false);\n const [summary, setSummary] = useState('');\n const [body, setBody] = useState('');\n const [format, setFormat] = useState<TcpStoryFormat>('ARTICLE');\n const [pickedTopic, setPickedTopic] = useState(topicId ?? '');\n const [languages, setLanguages] = useState<string[]>([]);\n const [tags, setTags] = useState<string[]>([]);\n const [readingMins, setReadingMins] = useState('');\n const [coverFileId, setCoverFileId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n // Bumped on reset to force the cover dropzone to drop its local preview state.\n const [resetNonce, setResetNonce] = useState(0);\n\n const effectiveSlug = slugTouched ? slug : slugify(title);\n\n const reset = () => {\n setTitle('');\n setSlug('');\n setSlugTouched(false);\n setSummary('');\n setBody('');\n setFormat('ARTICLE');\n setPickedTopic(topicId ?? '');\n setLanguages([]);\n setTags([]);\n setReadingMins('');\n setCoverFileId(null);\n setError(null);\n setResetNonce((n) => n + 1);\n };\n\n const submit = async () => {\n if (!title.trim()) {\n setError('A title is required.');\n return;\n }\n if (!effectiveSlug) {\n setError('A URL slug is required.');\n return;\n }\n try {\n const created = await createStory.mutateAsync({\n title: title.trim(),\n slug: effectiveSlug,\n summary: summary.trim() || null,\n body: body.trim() || null,\n format,\n topicId: pickedTopic || null,\n languages: languages.length ? languages : null,\n tags: tags.length ? tags : null,\n readingMins: readingMins ? Number(readingMins) : null,\n coverFileId,\n });\n notify.success('Story created', created.title);\n onOpenChange(false);\n reset();\n onCreated?.(created);\n } catch (err) {\n // Keep the dialog open with the entered values and surface the failure in\n // both the inline alert and a toast, so a failed create is never silent.\n const message = describeError(err);\n setError(message);\n notify.error('Could not create the story', message);\n }\n };\n\n return (\n <ResponsiveDialog open={open} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent\n className=\"flex max-h-[90dvh] flex-col overflow-hidden sm:max-w-3xl\"\n data-testid=\"create-story-dialog\"\n >\n <ResponsiveDialogHeader className=\"shrink-0\">\n <ResponsiveDialogTitle className=\"font-display\">Draft a story</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Begin a new piece — it enters the editorial lifecycle as a draft you can refine and\n publish later.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div\n data-testid=\"create-story-dialog-body\"\n className=\"flex min-h-0 max-h-[52dvh] flex-1 flex-col gap-5 overflow-y-auto overscroll-contain py-2 pe-1 md:max-h-none\"\n >\n {/* Cover image */}\n <div className=\"grid gap-1.5\">\n <Label>Cover image</Label>\n <CoverDropzone\n key={resetNonce}\n coverFileId={coverFileId}\n onUploaded={setCoverFileId}\n onCleared={() => setCoverFileId(null)}\n />\n </div>\n\n {/* Title + slug */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-title\">Title</Label>\n <Input\n id=\"story-title\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder=\"e.g. The Weavers of the Coromandel Coast\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-slug\">URL slug</Label>\n <div className=\"relative\">\n <Input\n id=\"story-slug\"\n value={effectiveSlug}\n onChange={(e) => {\n setSlugTouched(true);\n setSlug(slugify(e.target.value));\n }}\n placeholder=\"the-weavers-of-the-coromandel-coast\"\n className={effectiveSlug ? 'pe-9' : undefined}\n />\n {effectiveSlug && (\n <CheckCircle2\n className=\"pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-status-success-text\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n <p className=\"text-xs text-text-tertiary\">\n Auto-derived from the title — used in the story’s URL, so keep it unique.\n </p>\n </div>\n </div>\n\n {/* Format + reading time */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label>Format</Label>\n <Select value={format} onValueChange={(v) => setFormat(v as TcpStoryFormat)}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {FORMATS.map((f) => (\n <SelectItem key={f} value={f}>\n {formatEnumLabel(f)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-reading\">Reading time (min)</Label>\n <Input\n id=\"story-reading\"\n type=\"number\"\n min={0}\n value={readingMins}\n onChange={(e) => setReadingMins(e.target.value)}\n placeholder=\"Optional\"\n />\n </div>\n </div>\n\n {/* Topic */}\n <div className=\"grid gap-1.5\">\n <Label>Topic</Label>\n <Select value={pickedTopic} onValueChange={setPickedTopic}>\n <SelectTrigger>\n <SelectValue placeholder=\"Choose a topic (optional)\" />\n </SelectTrigger>\n <SelectContent>\n {(topicsQuery.data?.items ?? []).map((topic) => (\n <SelectItem key={topic.id} value={topic.id}>\n {topic.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Summary */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-summary\">Summary</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {summary.length}/{SUMMARY_MAX}\n </span>\n </div>\n <Textarea\n id=\"story-summary\"\n value={summary}\n onChange={(e) => setSummary(e.target.value.slice(0, SUMMARY_MAX))}\n maxLength={SUMMARY_MAX}\n placeholder=\"A short standfirst that introduces the story.\"\n rows={2}\n />\n </div>\n\n <FramingPrompts />\n\n {/* Body */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-body\">Body</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {body.length} {body.length === 1 ? 'character' : 'characters'}\n </span>\n </div>\n <Textarea\n id=\"story-body\"\n value={body}\n onChange={(e) => setBody(e.target.value)}\n placeholder=\"Write the story… (line breaks are preserved)\"\n rows={5}\n />\n </div>\n\n {/* Languages + tags */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-langs\">Languages</Label>\n <TagInput\n id=\"story-langs\"\n value={languages}\n onChange={setLanguages}\n placeholder=\"e.g. English, Tamil…\"\n preserveCase\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-tags\">Tags</Label>\n <TagInput id=\"story-tags\" value={tags} onChange={setTags} placeholder=\"Add tags…\" />\n </div>\n </div>\n\n {error && <p className=\"text-sm text-status-error-text\">{error}</p>}\n </div>\n\n <ResponsiveDialogFooter\n data-testid=\"create-story-dialog-footer\"\n className=\"shrink-0 border-t border-border-seam pt-3\"\n >\n <Button variant=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={createStory.isPending}>\n {createStory.isPending ? (\n <>\n <Loader2 className=\"me-1.5 h-4 w-4 animate-spin\" aria-hidden=\"true\" /> Creating…\n </>\n ) : (\n 'Create story'\n )}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,IAAME,KAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAc,KACdC,IAAe;AAYrB,SAASC,GAAc,EAAE,gBAAa,eAAY,gBAAiC;CACj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AX","COVER_MAX_MB","CoverDropzone","inputRef","useRef","uploading","setUploading","useState","dragActive","setDragActive","previewUrl","setPreviewUrl","fileName","setFileName","handleFile","file","uploaded","uploadImageToFiles","FILE_FOLDERS","onUploaded","notify","err","describeError","onInputChange","event","onDrop","clear","onCleared","hiddenInput","X","coverFileId","FileCheck2","cn","Loader2","UploadCloud","Button","CreateStoryDialog","createStory","useTcpCreateStory","topicsQuery","useTcpTopics","title","setTitle","slug","setSlug","slugTouched","setSlugTouched","summary","setSummary","body","setBody","format","setFormat","pickedTopic","setPickedTopic","topicId","languages","setLanguages","tags","setTags","readingMins","setReadingMins","setCoverFileId","error","setError","resetNonce","setResetNonce","effectiveSlug","slugify","reset","n","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","Label","Input","CheckCircle2","Select","v","SelectTrigger","SelectValue","SelectContent","SelectItem","f","formatEnumLabel","topic","Textarea","FramingPrompts","TagInput","ResponsiveDialogFooter","onOpenChange","created","onCreated","message"],"sources":["../../../src/theculturepost/components/CreateStoryDialog.tsx"],"sourcesContent":["/**\n * CreateStoryDialog — draft a new story.\n * @module theculturepost/components\n *\n * Writes `tcpCreateStory`. A wide, two-column composer that mirrors the editorial\n * \"Draft a story\" surface: a real drag-and-drop cover dropzone (uploads to\n * wspace-files-svc and keeps the returned `coverFileId`), a title with an\n * auto-derived URL slug + uniqueness hint, char counters on summary/body, and\n * chip multiselects for languages/tags. New stories begin at the start of the\n * editorial lifecycle (IDEA/DRAFT on the svc). Every field maps to a real\n * `TcpCreateStoryInput` field — no bookmarks, no fabricated metadata.\n */\n\nimport { useRef, useState, type ChangeEvent, type DragEvent } from 'react';\nimport { UploadCloud, Loader2, X, CheckCircle2, FileCheck2 } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n} from '@burdenoff/fe-libs/ui';\nimport { FramingPrompts } from './FramingPrompts';\nimport { TagInput } from './TagInput';\nimport { cn } from '../utils/cn';\nimport { useTcpCreateStory, useTcpTopics, uploadImageToFiles, FILE_FOLDERS } from '../hooks';\nimport { slugify } from '../utils/slug';\nimport { formatEnumLabel } from '../utils/formatters';\nimport { notify, describeError } from '../lib/toast';\nimport type { TcpStory, TcpStoryFormat } from '../types';\n\nconst FORMATS: TcpStoryFormat[] = [\n 'ARTICLE',\n 'ESSAY',\n 'EXPLAINER',\n 'ORAL_HISTORY',\n 'PHOTO_STORY',\n 'TIMELINE',\n];\n\nconst SUMMARY_MAX = 200;\nconst COVER_MAX_MB = 25;\n\n// ---------------------------------------------------------------------------\n// Cover dropzone (real drag-and-drop → wspace-files-svc)\n// ---------------------------------------------------------------------------\n\ninterface CoverDropzoneProps {\n coverFileId: string | null;\n onUploaded: (fileId: string) => void;\n onCleared: () => void;\n}\n\nfunction CoverDropzone({ coverFileId, onUploaded, onCleared }: CoverDropzoneProps) {\n const inputRef = useRef<HTMLInputElement | null>(null);\n const [uploading, setUploading] = useState(false);\n const [dragActive, setDragActive] = useState(false);\n const [previewUrl, setPreviewUrl] = useState<string | null>(null);\n const [fileName, setFileName] = useState<string | null>(null);\n\n const handleFile = async (file: File) => {\n if (!file.type.startsWith('image/')) {\n notify.error('Unsupported file', 'Please choose an image (JPG or PNG).');\n return;\n }\n if (file.size > COVER_MAX_MB * 1024 * 1024) {\n notify.error('File too large', `Please choose an image under ${COVER_MAX_MB} MB.`);\n return;\n }\n setUploading(true);\n try {\n const uploaded = await uploadImageToFiles(file, FILE_FOLDERS.covers);\n setPreviewUrl(uploaded.url);\n setFileName(uploaded.name);\n onUploaded(uploaded.id);\n notify.success('Cover uploaded', uploaded.name);\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n const onInputChange = (event: ChangeEvent<HTMLInputElement>) => {\n const file = event.target.files?.[0];\n event.target.value = '';\n if (file) void handleFile(file);\n };\n\n const onDrop = (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n setDragActive(false);\n if (uploading) return;\n const file = event.dataTransfer.files?.[0];\n if (file) void handleFile(file);\n };\n\n const clear = () => {\n setPreviewUrl(null);\n setFileName(null);\n onCleared();\n };\n\n const hiddenInput = (\n <input\n ref={inputRef}\n type=\"file\"\n accept=\"image/*\"\n className=\"sr-only\"\n onChange={onInputChange}\n disabled={uploading}\n aria-label=\"Upload cover image\"\n />\n );\n\n // Uploaded image preview\n if (previewUrl) {\n return (\n <div className=\"relative overflow-hidden rounded-2xl border border-border-seam\">\n {hiddenInput}\n <img src={previewUrl} alt=\"Cover preview\" className=\"max-h-52 w-full object-cover\" />\n <div className=\"absolute end-2 top-2 flex gap-1.5\">\n <button\n type=\"button\"\n onClick={() => inputRef.current?.click()}\n className=\"rounded-full bg-bg-canvas/85 px-2.5 py-1 text-xs font-medium text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n Replace\n </button>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"rounded-full bg-bg-canvas/85 p-1.5 text-text-primary backdrop-blur-sm hover:bg-bg-canvas\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n </div>\n );\n }\n\n // Cover set but no local preview (defensive)\n if (coverFileId) {\n return (\n <div className=\"flex items-center justify-between gap-2 rounded-2xl border border-border-seam bg-bg-surface px-3 py-2.5 text-sm\">\n {hiddenInput}\n <span className=\"inline-flex min-w-0 items-center gap-2 text-text-primary\">\n <FileCheck2 className=\"h-4 w-4 shrink-0 text-status-success-text\" aria-hidden=\"true\" />\n <span className=\"truncate\">{fileName ?? 'Cover selected'}</span>\n </span>\n <button\n type=\"button\"\n onClick={clear}\n aria-label=\"Remove cover\"\n className=\"text-text-tertiary hover:text-text-primary\"\n >\n <X className=\"h-4 w-4\" aria-hidden=\"true\" />\n </button>\n </div>\n );\n }\n\n // Empty dropzone\n return (\n <div\n onDragOver={(event) => {\n event.preventDefault();\n if (!uploading) setDragActive(true);\n }}\n onDragLeave={(event) => {\n event.preventDefault();\n setDragActive(false);\n }}\n onDrop={onDrop}\n className={cn(\n 'rounded-2xl border-2 border-dashed px-4 py-6 text-center transition-colors',\n dragActive\n ? 'border-accent bg-[var(--color-accent-soft)]'\n : 'border-border-seam bg-bg-sunken/40'\n )}\n >\n {hiddenInput}\n {uploading ? (\n <div className=\"flex items-center justify-center gap-2 text-sm text-text-secondary\">\n <Loader2 className=\"h-5 w-5 animate-spin\" aria-hidden=\"true\" /> Uploading cover…\n </div>\n ) : (\n <div className=\"flex flex-col items-center justify-center gap-3 sm:flex-row\">\n <UploadCloud className=\"h-8 w-8 text-text-link\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">Drag and drop an image here, or</p>\n <Button type=\"button\" size=\"sm\" onClick={() => inputRef.current?.click()}>\n Upload cover\n </Button>\n </div>\n )}\n <p className=\"mt-3 text-xs text-text-tertiary\">\n Recommended: 16:9 ratio, min 1200×675px. JPG or PNG, up to {COVER_MAX_MB} MB.\n </p>\n </div>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Dialog\n// ---------------------------------------------------------------------------\n\ninterface CreateStoryDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n /** Pre-select a topic (e.g. from a topic detail page). */\n topicId?: string;\n onCreated?: (story: TcpStory) => void;\n}\n\nexport function CreateStoryDialog({\n open,\n onOpenChange,\n topicId,\n onCreated,\n}: CreateStoryDialogProps) {\n const createStory = useTcpCreateStory();\n const topicsQuery = useTcpTopics({ pagination: { limit: 100 } });\n\n const [title, setTitle] = useState('');\n const [slug, setSlug] = useState('');\n const [slugTouched, setSlugTouched] = useState(false);\n const [summary, setSummary] = useState('');\n const [body, setBody] = useState('');\n const [format, setFormat] = useState<TcpStoryFormat>('ARTICLE');\n const [pickedTopic, setPickedTopic] = useState(topicId ?? '');\n const [languages, setLanguages] = useState<string[]>([]);\n const [tags, setTags] = useState<string[]>([]);\n const [readingMins, setReadingMins] = useState('');\n const [coverFileId, setCoverFileId] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n // Bumped on reset to force the cover dropzone to drop its local preview state.\n const [resetNonce, setResetNonce] = useState(0);\n\n const effectiveSlug = slugTouched ? slug : slugify(title);\n\n const reset = () => {\n setTitle('');\n setSlug('');\n setSlugTouched(false);\n setSummary('');\n setBody('');\n setFormat('ARTICLE');\n setPickedTopic(topicId ?? '');\n setLanguages([]);\n setTags([]);\n setReadingMins('');\n setCoverFileId(null);\n setError(null);\n setResetNonce((n) => n + 1);\n };\n\n const submit = async () => {\n if (!title.trim()) {\n setError('A title is required.');\n return;\n }\n if (!effectiveSlug) {\n setError('A URL slug is required.');\n return;\n }\n try {\n const created = await createStory.mutateAsync({\n title: title.trim(),\n slug: effectiveSlug,\n summary: summary.trim() || null,\n body: body.trim() || null,\n format,\n topicId: pickedTopic || null,\n languages: languages.length ? languages : null,\n tags: tags.length ? tags : null,\n readingMins: readingMins ? Number(readingMins) : null,\n coverFileId,\n });\n notify.success('Story created', created.title);\n onOpenChange(false);\n reset();\n onCreated?.(created);\n } catch (err) {\n // Keep the dialog open with the entered values and surface the failure in\n // both the inline alert and a toast, so a failed create is never silent.\n const message = describeError(err);\n setError(message);\n notify.error('Could not create the story', message);\n }\n };\n\n return (\n <ResponsiveDialog open={open} onOpenChange={onOpenChange}>\n <ResponsiveDialogContent\n className=\"flex max-h-[90dvh] flex-col overflow-hidden sm:max-w-3xl\"\n data-testid=\"create-story-dialog\"\n >\n <ResponsiveDialogHeader className=\"shrink-0\">\n <ResponsiveDialogTitle className=\"font-display\">Draft a story</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Begin a new piece — it enters the editorial lifecycle as a draft you can refine and\n publish later.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div\n data-testid=\"create-story-dialog-body\"\n className=\"flex min-h-0 max-h-[52dvh] flex-1 flex-col gap-5 overflow-y-auto overscroll-contain py-2 pe-1 md:max-h-none\"\n >\n {/* Cover image */}\n <div className=\"grid gap-1.5\">\n <Label>Cover image</Label>\n <CoverDropzone\n key={resetNonce}\n coverFileId={coverFileId}\n onUploaded={setCoverFileId}\n onCleared={() => setCoverFileId(null)}\n />\n </div>\n\n {/* Title + slug */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-title\">Title</Label>\n <Input\n id=\"story-title\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n placeholder=\"e.g. The Weavers of the Coromandel Coast\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-slug\">URL slug</Label>\n <div className=\"relative\">\n <Input\n id=\"story-slug\"\n value={effectiveSlug}\n onChange={(e) => {\n setSlugTouched(true);\n setSlug(slugify(e.target.value));\n }}\n placeholder=\"the-weavers-of-the-coromandel-coast\"\n className={effectiveSlug ? 'pe-9' : undefined}\n />\n {effectiveSlug && (\n <CheckCircle2\n className=\"pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-status-success-text\"\n aria-hidden=\"true\"\n />\n )}\n </div>\n <p className=\"text-xs text-text-tertiary\">\n Auto-derived from the title — used in the story’s URL, so keep it unique.\n </p>\n </div>\n </div>\n\n {/* Format + reading time */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label>Format</Label>\n <Select value={format} onValueChange={(v) => setFormat(v as TcpStoryFormat)}>\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {FORMATS.map((f) => (\n <SelectItem key={f} value={f}>\n {formatEnumLabel(f)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-reading\">Reading time (min)</Label>\n <Input\n id=\"story-reading\"\n type=\"number\"\n min={0}\n value={readingMins}\n onChange={(e) => setReadingMins(e.target.value)}\n placeholder=\"Optional\"\n />\n </div>\n </div>\n\n {/* Topic */}\n <div className=\"grid gap-1.5\">\n <Label>Topic</Label>\n <Select value={pickedTopic} onValueChange={setPickedTopic}>\n <SelectTrigger>\n <SelectValue placeholder=\"Choose a topic (optional)\" />\n </SelectTrigger>\n <SelectContent>\n {(topicsQuery.data?.items ?? []).map((topic) => (\n <SelectItem key={topic.id} value={topic.id}>\n {topic.name}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n {/* Summary */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-summary\">Summary</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {summary.length}/{SUMMARY_MAX}\n </span>\n </div>\n <Textarea\n id=\"story-summary\"\n value={summary}\n onChange={(e) => setSummary(e.target.value.slice(0, SUMMARY_MAX))}\n maxLength={SUMMARY_MAX}\n placeholder=\"A short standfirst that introduces the story.\"\n rows={2}\n />\n </div>\n\n <FramingPrompts />\n\n {/* Body */}\n <div className=\"grid gap-1.5\">\n <div className=\"flex items-center justify-between gap-2\">\n <Label htmlFor=\"story-body\">Body</Label>\n <span className=\"text-xs tabular-nums text-text-tertiary\">\n {body.length} {body.length === 1 ? 'character' : 'characters'}\n </span>\n </div>\n <Textarea\n id=\"story-body\"\n value={body}\n onChange={(e) => setBody(e.target.value)}\n placeholder=\"Write the story… (line breaks are preserved)\"\n rows={5}\n />\n </div>\n\n {/* Languages + tags */}\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-langs\">Languages</Label>\n <TagInput\n id=\"story-langs\"\n value={languages}\n onChange={setLanguages}\n placeholder=\"e.g. English, Tamil…\"\n preserveCase\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"story-tags\">Tags</Label>\n <TagInput id=\"story-tags\" value={tags} onChange={setTags} placeholder=\"Add tags…\" />\n </div>\n </div>\n\n {error && <p className=\"text-sm text-status-error-text\">{error}</p>}\n </div>\n\n <ResponsiveDialogFooter\n data-testid=\"create-story-dialog-footer\"\n className=\"shrink-0 border-t border-border-seam pt-3\"\n >\n <Button variant=\"outline\" onClick={() => onOpenChange(false)}>\n Cancel\n </Button>\n <Button onClick={submit} disabled={createStory.isPending}>\n {createStory.isPending ? (\n <>\n <Loader2 className=\"me-1.5 h-4 w-4 animate-spin\" aria-hidden=\"true\" /> Creating…\n </>\n ) : (\n 'Create story'\n )}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAyCA,IAAME,KAA4B;CAChC;CACA;CACA;CACA;CACA;CACA;AACF,GAEMC,IAAc,KACdC,IAAe;AAYrB,SAASC,GAAc,EAAE,gBAAa,eAAY,gBAAiC;CACjF,IAAMC,IAAWC,EAAgC,IAAI,GAC/C,CAACC,GAAWC,KAAgBC,EAAS,EAAK,GAC1C,CAACC,GAAYC,KAAiBF,EAAS,EAAK,GAC5C,CAACG,GAAYC,KAAiBJ,EAAwB,IAAI,GAC1D,CAACK,GAAUC,KAAeN,EAAwB,IAAI,GAEtDO,IAAa,OAAO,MAAe;EACvC,IAAI,CAACC,EAAK,KAAK,WAAW,QAAQ,GAChC,EAAO,MAAM,oBAAoB,sCAAsC;OAGzE,IAAIA,EAAK,OAAOd,IAAe,OAAO,MACpC,EAAO,MAAM,kBAAkB,gCAAgCA,EAAa,KAAK;OAGnF;KAAa,EAAI;GACjB,IAAI;IACF,IAAMe,IAAW,MAAMC,EAAmBF,GAAMG,EAAa,MAAM;IAInE,AAHAP,EAAcK,EAAS,GAAG,GAC1BH,EAAYG,EAAS,IAAI,GACzBG,EAAWH,EAAS,EAAE,GACtBI,EAAO,QAAQ,kBAAkBJ,EAAS,IAAI;GAChD,SAASK,GAAK;IACZ,EAAO,MAAM,iBAAiBC,GAAcD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SAC3B,aAAaE,IAAc,OAAOA,CAAW,IAAI;SACjD;QACF,CAAC;QAID,AAHAxC,EAAO,QAAQ,iBAAiByE,EAAQ,KAAK,GAC7CD,EAAa,EAAK,GAClBvB,GAAM,GACNyB,IAAYD,CAAO;OACrB,SAASxE,GAAK;QAGZ,IAAM0E,IAAUzE,GAAcD,CAAG;QAEjC,AADA2C,EAAS+B,CAAO,GAChB3E,EAAO,MAAM,8BAA8B2E,CAAO;OACpD;MACF;MAoLiC,UAAU1D,EAAY;MAC5C,UAAAA,EAAY,YACX,kBAAAxC,GAAA,EAAA,UAAA,CACE,kBAACoC,GAAD;OAAS,WAAU;OAA8B,eAAY;MAAQ,CAAA,GAAC,YACtE,EAAA,CAAA,IAEF;KAEI,CAAA,CACc;;GACD;;CACT,CAAA;AAEtB"}
|
|
@@ -28,7 +28,7 @@ function o({ className: o }) {
|
|
|
28
28
|
className: "flex cursor-pointer items-center gap-2 text-sm font-medium text-text-primary",
|
|
29
29
|
children: [
|
|
30
30
|
/* @__PURE__ */ r(n, {
|
|
31
|
-
className: "h-4 w-4 text-
|
|
31
|
+
className: "h-4 w-4 text-text-link",
|
|
32
32
|
"aria-hidden": "true"
|
|
33
33
|
}),
|
|
34
34
|
s("framing.title", "Framing prompts"),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FramingPrompts.js","names":["FRAMING_PROMPTS","FramingPrompts","tr","useTr","cn","className","Lightbulb","prompt"],"sources":["../../../src/theculturepost/components/FramingPrompts.tsx"],"sourcesContent":["import { Lightbulb } from 'lucide-react';\nimport { useTr } from '../hooks';\nimport { cn } from '../utils/cn';\n\nexport interface FramingPrompt {\n key: string;\n fallback: string;\n}\n\n/** Prompts in display order. Exported so tests can pin the i18n keys. */\nexport const FRAMING_PROMPTS: readonly FramingPrompt[] = [\n {\n key: 'framing.perspective',\n fallback: 'Whose perspective is this told from, and whose is missing?',\n },\n {\n key: 'framing.contested',\n fallback: 'Which points are contested? Present the other views fairly.',\n },\n {\n key: 'framing.sourceLimits',\n fallback: 'What are the limits of your sources? Say what they cannot show.',\n },\n];\n\nexport function FramingPrompts({ className }: { className?: string }) {\n const tr = useTr();\n return (\n <details\n open\n data-testid=\"framing-prompts\"\n className={cn(\n 'rounded-xl border border-border-seam bg-[var(--color-accent-soft)] px-3 py-2',\n className\n )}\n >\n <summary className=\"flex cursor-pointer items-center gap-2 text-sm font-medium text-text-primary\">\n <Lightbulb className=\"h-4 w-4 text-
|
|
1
|
+
{"version":3,"file":"FramingPrompts.js","names":["FRAMING_PROMPTS","FramingPrompts","tr","useTr","cn","className","Lightbulb","prompt"],"sources":["../../../src/theculturepost/components/FramingPrompts.tsx"],"sourcesContent":["import { Lightbulb } from 'lucide-react';\nimport { useTr } from '../hooks';\nimport { cn } from '../utils/cn';\n\nexport interface FramingPrompt {\n key: string;\n fallback: string;\n}\n\n/** Prompts in display order. Exported so tests can pin the i18n keys. */\nexport const FRAMING_PROMPTS: readonly FramingPrompt[] = [\n {\n key: 'framing.perspective',\n fallback: 'Whose perspective is this told from, and whose is missing?',\n },\n {\n key: 'framing.contested',\n fallback: 'Which points are contested? Present the other views fairly.',\n },\n {\n key: 'framing.sourceLimits',\n fallback: 'What are the limits of your sources? Say what they cannot show.',\n },\n];\n\nexport function FramingPrompts({ className }: { className?: string }) {\n const tr = useTr();\n return (\n <details\n open\n data-testid=\"framing-prompts\"\n className={cn(\n 'rounded-xl border border-border-seam bg-[var(--color-accent-soft)] px-3 py-2',\n className\n )}\n >\n <summary className=\"flex cursor-pointer items-center gap-2 text-sm font-medium text-text-primary\">\n <Lightbulb className=\"h-4 w-4 text-text-link\" aria-hidden=\"true\" />\n {tr('framing.title', 'Framing prompts')}\n <span className=\"text-xs font-normal text-text-tertiary\">\n {tr('framing.hint', 'Optional — context and care')}\n </span>\n </summary>\n <ul className=\"mt-2 flex list-disc flex-col gap-1 pb-1 ps-9 text-sm text-text-secondary\">\n {FRAMING_PROMPTS.map((prompt) => (\n <li key={prompt.key}>{tr(prompt.key, prompt.fallback)}</li>\n ))}\n </ul>\n </details>\n );\n}\n"],"mappings":";;;;;;AAUA,IAAaA,IAA4C;CACvD;EACE,KAAK;EACL,UAAU;CACZ;CACA;EACE,KAAK;EACL,UAAU;CACZ;CACA;EACE,KAAK;EACL,UAAU;CACZ;AACF;AAEA,SAAgBC,EAAe,EAAE,gBAAqC;CACpE,IAAMC,IAAKC,EAAM;CACjB,OACE,kBAAC,WAAD;EACE,MAAA;EACA,eAAY;EACZ,WAAWC,EACT,gFACAC,CACF;EANF,UAAA,CAQE,kBAAC,WAAD;GAAS,WAAU;GAAnB,UAAA;IACE,kBAACC,GAAD;KAAW,WAAU;KAAyB,eAAY;IAAQ,CAAA;IACjEJ,EAAG,iBAAiB,iBAAiB;IACtC,kBAAC,QAAD;KAAM,WAAU;KACb,UAAAA,EAAG,gBAAgB,6BAA6B;IAC7C,CAAA;GACC;EACT,CAAA,GAAA,kBAAC,MAAD;GAAI,WAAU;GACX,UAAAF,EAAgB,KAAK,MACpB,kBAAC,MAAD,EAAA,UAAsBE,EAAGK,EAAO,KAAKA,EAAO,QAAQ,EAAM,GAAjDA,EAAO,GAA0C,CAC3D;EACC,CAAA,CACG;;AAEb"}
|
|
@@ -14,7 +14,7 @@ function a({ entry: t, above: a }) {
|
|
|
14
14
|
className: e("flex w-full flex-col gap-1 rounded-xl border border-border-seam bg-bg-surface p-4 text-start shadow-sm", s && "transition-shadow hover:shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-accent)]", a ? "md:self-end" : "md:self-start"),
|
|
15
15
|
children: [
|
|
16
16
|
/* @__PURE__ */ r("span", {
|
|
17
|
-
className: "text-xs font-semibold uppercase tracking-wide text-
|
|
17
|
+
className: "text-xs font-semibold uppercase tracking-wide text-text-link",
|
|
18
18
|
children: t.date
|
|
19
19
|
}),
|
|
20
20
|
/* @__PURE__ */ r("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HistoryTimeline.js","names":["EntryCard","Icon","entry","Milestone","interactive","cn","above","HistoryTimeline","labelId","useId","entries","className","i"],"sources":["../../../src/theculturepost/components/HistoryTimeline.tsx"],"sourcesContent":["/**\n * HistoryTimeline — a responsive, alternating-axis timeline of dated entries.\n * @module theculturepost/components\n *\n * Desktop (md+): a horizontal spine with cards alternating above / below each\n * node, scrolling horizontally when the entries overflow. Mobile: a vertical\n * spine with all cards stacked on one side. Token-only. Cards are optionally\n * clickable via `onOpen`. Dates are shown verbatim (the schema stores free-text\n * era/date strings) — never reformatted or fabricated.\n */\n\nimport { useId } from 'react';\nimport type { LucideIcon } from 'lucide-react';\nimport { Milestone } from 'lucide-react';\nimport { cn } from '../utils/cn';\n\nexport interface TimelineEntry {\n id: string;\n /** Verbatim date/era label (e.g. \"1054 CE\", \"c. 2000 BCE\"). */\n date: string;\n title: string;\n subtitle?: string;\n /** Small kind/category chip shown on the card. */\n kind?: string;\n icon?: LucideIcon;\n onOpen?: () => void;\n}\n\ninterface HistoryTimelineProps {\n entries: TimelineEntry[];\n className?: string;\n}\n\nfunction EntryCard({ entry, above }: { entry: TimelineEntry; above: boolean }) {\n const Icon = entry.icon ?? Milestone;\n const interactive = Boolean(entry.onOpen);\n const Wrapper = interactive ? 'button' : 'div';\n\n return (\n <Wrapper\n {...(interactive\n ? { type: 'button' as const, onClick: entry.onOpen, 'aria-label': `Open ${entry.title}` }\n : {})}\n className={cn(\n 'flex w-full flex-col gap-1 rounded-xl border border-border-seam bg-bg-surface p-4 text-start shadow-sm',\n interactive &&\n 'transition-shadow hover:shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-accent)]',\n // point the card toward the spine\n above ? 'md:self-end' : 'md:self-start'\n )}\n >\n <span className=\"text-xs font-semibold uppercase tracking-wide text-
|
|
1
|
+
{"version":3,"file":"HistoryTimeline.js","names":["EntryCard","Icon","entry","Milestone","interactive","cn","above","HistoryTimeline","labelId","useId","entries","className","i"],"sources":["../../../src/theculturepost/components/HistoryTimeline.tsx"],"sourcesContent":["/**\n * HistoryTimeline — a responsive, alternating-axis timeline of dated entries.\n * @module theculturepost/components\n *\n * Desktop (md+): a horizontal spine with cards alternating above / below each\n * node, scrolling horizontally when the entries overflow. Mobile: a vertical\n * spine with all cards stacked on one side. Token-only. Cards are optionally\n * clickable via `onOpen`. Dates are shown verbatim (the schema stores free-text\n * era/date strings) — never reformatted or fabricated.\n */\n\nimport { useId } from 'react';\nimport type { LucideIcon } from 'lucide-react';\nimport { Milestone } from 'lucide-react';\nimport { cn } from '../utils/cn';\n\nexport interface TimelineEntry {\n id: string;\n /** Verbatim date/era label (e.g. \"1054 CE\", \"c. 2000 BCE\"). */\n date: string;\n title: string;\n subtitle?: string;\n /** Small kind/category chip shown on the card. */\n kind?: string;\n icon?: LucideIcon;\n onOpen?: () => void;\n}\n\ninterface HistoryTimelineProps {\n entries: TimelineEntry[];\n className?: string;\n}\n\nfunction EntryCard({ entry, above }: { entry: TimelineEntry; above: boolean }) {\n const Icon = entry.icon ?? Milestone;\n const interactive = Boolean(entry.onOpen);\n const Wrapper = interactive ? 'button' : 'div';\n\n return (\n <Wrapper\n {...(interactive\n ? { type: 'button' as const, onClick: entry.onOpen, 'aria-label': `Open ${entry.title}` }\n : {})}\n className={cn(\n 'flex w-full flex-col gap-1 rounded-xl border border-border-seam bg-bg-surface p-4 text-start shadow-sm',\n interactive &&\n 'transition-shadow hover:shadow-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-accent)]',\n // point the card toward the spine\n above ? 'md:self-end' : 'md:self-start'\n )}\n >\n <span className=\"text-xs font-semibold uppercase tracking-wide text-text-link\">\n {entry.date}\n </span>\n <span className=\"font-display text-base font-semibold leading-snug text-text-primary\">\n {entry.title}\n </span>\n {entry.subtitle && (\n <span className=\"line-clamp-2 text-sm text-text-secondary\">{entry.subtitle}</span>\n )}\n {entry.kind && (\n <span className=\"mt-1 inline-flex w-fit items-center gap-1 rounded-full bg-[var(--color-accent-soft)] px-2 py-0.5 text-xs font-medium text-text-primary\">\n <Icon className=\"h-3 w-3\" aria-hidden=\"true\" /> {entry.kind}\n </span>\n )}\n </Wrapper>\n );\n}\n\nexport function HistoryTimeline({ entries, className }: HistoryTimelineProps) {\n const labelId = useId();\n\n if (entries.length === 0) {\n return <p className={cn('text-sm text-text-tertiary', className)}>No timeline entries yet.</p>;\n }\n\n return (\n <section aria-labelledby={labelId} className={cn('w-full', className)}>\n <h2 id={labelId} className=\"sr-only\">\n Timeline\n </h2>\n\n {/* Mobile: vertical spine */}\n <ol className=\"relative space-y-6 border-s border-border-seam ps-6 md:hidden\">\n {entries.map((entry) => (\n <li key={entry.id} className=\"relative\">\n <span\n className=\"absolute -start-[1.6rem] top-1.5 h-3 w-3 rounded-full border-2 border-bg-canvas bg-accent\"\n aria-hidden=\"true\"\n />\n <EntryCard entry={entry} above={false} />\n </li>\n ))}\n </ol>\n\n {/* Desktop: horizontal alternating spine, scrolls on overflow */}\n <div className=\"hidden overflow-x-auto pb-2 md:block\">\n <ol className=\"flex min-w-full items-stretch gap-6\">\n {entries.map((entry, i) => {\n const above = i % 2 === 0;\n return (\n <li\n key={entry.id}\n className=\"flex w-64 shrink-0 flex-col justify-center\"\n aria-setsize={entries.length}\n aria-posinset={i + 1}\n >\n <div className=\"flex min-h-[9rem] items-end\">\n {above && <EntryCard entry={entry} above />}\n </div>\n {/* spine node */}\n <div className=\"relative flex items-center py-3\">\n <span className=\"h-px w-full bg-border-seam\" aria-hidden=\"true\" />\n <span\n className=\"absolute left-1/2 h-3.5 w-3.5 -translate-x-1/2 rounded-full border-2 border-bg-canvas bg-accent\"\n aria-hidden=\"true\"\n />\n </div>\n <div className=\"flex min-h-[9rem] items-start\">\n {!above && <EntryCard entry={entry} above={false} />}\n </div>\n </li>\n );\n })}\n </ol>\n </div>\n </section>\n );\n}\n"],"mappings":";;;;;AAiCA,SAASA,EAAU,EAAE,UAAO,YAAmD;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