@burdenoff/microfe-cosmicintersection 2026.1031.1 → 2026.1101.2
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/cosmicintersection/CosmicIntersectionRoot.d.ts +0 -1
- package/dist/cosmicintersection/CosmicIntersectionRoot.js +2 -2
- package/dist/cosmicintersection/CosmicIntersectionRoutes.d.ts +1 -1
- package/dist/cosmicintersection/CosmicIntersectionRoutes.js +1 -1
- package/dist/cosmicintersection/api/cosmicApi.d.ts +0 -1
- package/dist/cosmicintersection/api/cosmicApi.js +82 -82
- package/dist/cosmicintersection/api/cosmicApi.js.map +1 -1
- package/dist/cosmicintersection/api/tagsApi.d.ts +100 -0
- package/dist/cosmicintersection/api/tagsApi.d.ts.map +1 -0
- package/dist/cosmicintersection/api/tagsApi.js +110 -0
- package/dist/cosmicintersection/api/tagsApi.js.map +1 -0
- package/dist/cosmicintersection/components/ActionMenu.d.ts +1 -2
- package/dist/cosmicintersection/components/ActionMenu.js +1 -1
- package/dist/cosmicintersection/components/ActivityFeedPanel.d.ts +1 -1
- package/dist/cosmicintersection/components/ActivityFeedPanel.js +4 -4
- package/dist/cosmicintersection/components/DiscussionPanel.d.ts +1 -1
- package/dist/cosmicintersection/components/DiscussionPanel.js +2 -2
- package/dist/cosmicintersection/components/EmptyState.d.ts +1 -2
- package/dist/cosmicintersection/components/EmptyState.js +1 -1
- package/dist/cosmicintersection/components/EntityFormShell.d.ts +1 -2
- package/dist/cosmicintersection/components/EntityFormShell.js +1 -1
- package/dist/cosmicintersection/components/EntityTagsField.d.ts +6 -6
- package/dist/cosmicintersection/components/EntityTagsField.js +1 -1
- package/dist/cosmicintersection/components/EntityTagsField.js.map +1 -1
- package/dist/cosmicintersection/components/ErrorState.d.ts +1 -1
- package/dist/cosmicintersection/components/ErrorState.js +1 -1
- package/dist/cosmicintersection/components/FacetPanel.d.ts +1 -1
- package/dist/cosmicintersection/components/FacetPanel.js +1 -1
- package/dist/cosmicintersection/components/FacetPanel.js.map +1 -1
- package/dist/cosmicintersection/components/FileUploadField.d.ts +1 -2
- package/dist/cosmicintersection/components/FileUploadField.js +1 -1
- package/dist/cosmicintersection/components/FileUploadField.js.map +1 -1
- package/dist/cosmicintersection/components/LineageGraph.d.ts +1 -2
- package/dist/cosmicintersection/components/LineageGraph.js +1 -1
- package/dist/cosmicintersection/components/LineageGraph.js.map +1 -1
- package/dist/cosmicintersection/components/LoadingState.d.ts +1 -1
- package/dist/cosmicintersection/components/LoadingState.js +1 -1
- package/dist/cosmicintersection/components/LoadingState.js.map +1 -1
- package/dist/cosmicintersection/components/PageLayout.d.ts +1 -2
- package/dist/cosmicintersection/components/PageLayout.js +1 -1
- package/dist/cosmicintersection/components/Pagination.d.ts +1 -1
- package/dist/cosmicintersection/components/Pagination.js +1 -1
- package/dist/cosmicintersection/components/ResultsChart.d.ts +1 -1
- package/dist/cosmicintersection/components/ResultsChart.js +4 -3
- package/dist/cosmicintersection/components/ResultsChart.js.map +1 -1
- package/dist/cosmicintersection/components/SafeLink.d.ts +1 -2
- package/dist/cosmicintersection/components/SafeLink.js +1 -1
- package/dist/cosmicintersection/components/StatusBadge.d.ts +1 -1
- package/dist/cosmicintersection/components/StatusBadge.js +1 -1
- package/dist/cosmicintersection/components/StatusBadge.js.map +1 -1
- package/dist/cosmicintersection/components/StepDAG.d.ts +1 -2
- package/dist/cosmicintersection/components/StepDAG.js +1 -1
- package/dist/cosmicintersection/components/StepDAG.js.map +1 -1
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.d.ts +27 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.d.ts.map +1 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js +141 -0
- package/dist/cosmicintersection/components/WorkspaceTagsPicker.js.map +1 -0
- package/dist/cosmicintersection/components/index.d.ts +1 -0
- package/dist/cosmicintersection/components/index.d.ts.map +1 -1
- package/dist/cosmicintersection/components/index.js +15 -13
- package/dist/cosmicintersection/context/CosmicIntersectionContext.d.ts +1 -2
- package/dist/cosmicintersection/context/CosmicIntersectionContext.js +2 -1
- package/dist/cosmicintersection/context/CosmicIntersectionContext.js.map +1 -1
- package/dist/cosmicintersection/hooks/useEntityTagSync.d.ts +49 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.d.ts.map +1 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.js +86 -0
- package/dist/cosmicintersection/hooks/useEntityTagSync.js.map +1 -0
- package/dist/cosmicintersection/lib/assistantAwareDialog.js +7 -5
- package/dist/cosmicintersection/lib/assistantAwareDialog.js.map +1 -1
- package/dist/cosmicintersection/lib/mutationResult.d.ts +0 -1
- package/dist/cosmicintersection/lib/toast.d.ts +0 -1
- package/dist/cosmicintersection/lib/toast.js +1 -1
- package/dist/cosmicintersection/lib/useSelectedRecord.js.map +1 -1
- package/dist/cosmicintersection/pages/access/AccessPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/access/AccessPage.js +10 -9
- package/dist/cosmicintersection/pages/access/AccessPage.js.map +1 -1
- package/dist/cosmicintersection/pages/analyses/AnalysesPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/analyses/AnalysesPage.js +8 -8
- package/dist/cosmicintersection/pages/analyses/AnalysesPage.js.map +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionDetailPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionDetailPage.js +7 -7
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.js +80 -78
- package/dist/cosmicintersection/pages/collections/CollectionFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionsPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/collections/CollectionsPage.js +5 -5
- package/dist/cosmicintersection/pages/collections/CollectionsPage.js.map +1 -1
- package/dist/cosmicintersection/pages/dashboard/DashboardPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/dashboard/DashboardPage.js +3 -3
- package/dist/cosmicintersection/pages/dashboard/DashboardPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js +124 -115
- package/dist/cosmicintersection/pages/datasets/DatasetDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.js +109 -106
- package/dist/cosmicintersection/pages/datasets/DatasetFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetsPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/datasets/DatasetsPage.js +7 -7
- package/dist/cosmicintersection/pages/datasets/DatasetsPage.js.map +1 -1
- package/dist/cosmicintersection/pages/discovery/DiscoveryPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/discovery/DiscoveryPage.js +6 -6
- package/dist/cosmicintersection/pages/discovery/DiscoveryPage.js.map +1 -1
- package/dist/cosmicintersection/pages/lineage/LineagePage.d.ts +1 -1
- package/dist/cosmicintersection/pages/lineage/LineagePage.js +5 -5
- package/dist/cosmicintersection/pages/lineage/LineagePage.js.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookDetailPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookDetailPage.js +7 -7
- package/dist/cosmicintersection/pages/notebooks/NotebookDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.js +143 -141
- package/dist/cosmicintersection/pages/notebooks/NotebookFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebooksPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/notebooks/NotebooksPage.js +7 -7
- package/dist/cosmicintersection/pages/notebooks/NotebooksPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineDetailPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineDetailPage.js +7 -7
- package/dist/cosmicintersection/pages/pipelines/PipelineDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js +214 -212
- package/dist/cosmicintersection/pages/pipelines/PipelineFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelinesPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/pipelines/PipelinesPage.js +7 -7
- package/dist/cosmicintersection/pages/pipelines/PipelinesPage.js.map +1 -1
- package/dist/cosmicintersection/pages/releases/ReleaseFormPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/releases/ReleaseFormPage.js +5 -4
- package/dist/cosmicintersection/pages/releases/ReleaseFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/releases/ReleasesPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/releases/ReleasesPage.js +9 -9
- package/dist/cosmicintersection/pages/releases/ReleasesPage.js.map +1 -1
- package/dist/cosmicintersection/pages/runs/RunDetailPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/runs/RunDetailPage.js +7 -7
- package/dist/cosmicintersection/pages/runs/RunDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/runs/RunsPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/runs/RunsPage.js +6 -6
- package/dist/cosmicintersection/pages/runs/RunsPage.js.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceDetailPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/sources/SourceDetailPage.js +7 -7
- package/dist/cosmicintersection/pages/sources/SourceDetailPage.js.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.d.ts.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourceFormPage.js +111 -108
- package/dist/cosmicintersection/pages/sources/SourceFormPage.js.map +1 -1
- package/dist/cosmicintersection/pages/sources/SourcesPage.d.ts +1 -1
- package/dist/cosmicintersection/pages/sources/SourcesPage.js +8 -8
- package/dist/cosmicintersection/pages/sources/SourcesPage.js.map +1 -1
- package/dist/cosmicintersection/types/index.d.ts +0 -1
- package/dist/cosmicintersection/utils/cn.d.ts +0 -1
- package/dist/cosmicintersection/utils/cn.js +1 -1
- package/dist/dev/main.d.ts +0 -1
- package/dist/generated/global-types.d.ts +2 -21
- package/dist/generated/global-types.d.ts.map +1 -1
- package/dist/generated/wspace-types.d.ts +2 -21
- package/dist/generated/wspace-types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/node_modules/clsx/dist/clsx.js +1 -1
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +130 -130
- package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js.map +1 -1
- package/dist/stories/EmptyState.stories.d.ts +0 -1
- package/dist/stories/LoadingState.stories.d.ts +0 -1
- package/dist/stories/StatusBadge.stories.d.ts +0 -1
- package/dist/stories/WorkspaceTagsPicker.stories.d.ts +12 -0
- package/dist/stories/WorkspaceTagsPicker.stories.d.ts.map +1 -0
- package/dist/test/fakeGateway.d.ts +0 -1
- package/dist/test/fixtures.d.ts +0 -1
- package/dist/test/renderWithProviders.d.ts +0 -1
- package/dist/test/setup.d.ts +0 -1
- package/dist/utils/pageContext.d.ts +0 -2
- package/dist/utils/pageContext.d.ts.map +1 -1
- package/dist/utils/pageContext.js +4 -6
- package/dist/utils/pageContext.js.map +1 -1
- package/package.json +44 -45
- package/dist/generated/global-operations.d.ts +0 -2
- package/dist/generated/global-operations.d.ts.map +0 -1
- package/dist/generated/wspace-operations.d.ts +0 -2
- package/dist/generated/wspace-operations.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResultsChart.js","names":[],"sources":["../../../src/cosmicintersection/components/ResultsChart.tsx"],"sourcesContent":["/**\n * ResultsChart — inline visualization for a completed analysis' `results` JSON.\n *\n * There is NO chart library here: axes, gridlines, scatter dots and line series\n * are hand-drawn as SVG using the design system's dataviz tokens\n * (`var(--color-chart-*)`, `var(--color-chart-axis)`, `var(--color-chart-grid)`)\n * plus the standard text tokens — never a raw palette colour. The SVG uses a\n * `viewBox` and `width:100%`, so it scales fluidly on phones (no horizontal\n * scroll).\n *\n * The `results` payload is free-form JSON (whatever `cosCompleteAnalysis` stored),\n * so the component sniffs it for numeric series. Accepted shapes:\n * - `results.series: Array<{ name?, kind?: 'line'|'scatter', points }>`\n * - `results.points` (scatter) and/or `results.fit` / `results.model` (line)\n * - any top-level numeric arrays (rendered as line series)\n * where a `points` array may hold `{x,y}` objects, `[x,y]` pairs, `{value}` /\n * `{y}` objects, or bare numbers (index used as x).\n *\n * When nothing chartable is found, a compact, responsive key/value metrics list\n * is rendered instead. Everything comes from the real payload — nothing is\n * fabricated; an empty payload renders an honest \"no results\" message.\n */\nimport { useMemo } from 'react';\n\nimport { cn } from '../utils/cn';\n\ntype Json = Record<string, unknown>;\n\ninterface Point {\n x: number;\n y: number;\n}\n\ntype SeriesKind = 'line' | 'scatter';\n\ninterface Series {\n name: string;\n kind: SeriesKind;\n points: Point[];\n colorVar: string;\n}\n\nconst SERIES_PALETTE = [1, 2, 3, 4, 5, 6].map((n) => `var(--color-chart-${n})`);\n\nconst MAX_POINTS_PER_SERIES = 600;\n\n// ---------------------------------------------------------------------------\n// Payload parsing\n// ---------------------------------------------------------------------------\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\nfunction humanize(key: string): string {\n const spaced = key\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim();\n if (!spaced) {\n return key;\n }\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\n/** Coerce a single raw element into a {x,y} point (index is the fallback x). */\nfunction toPoint(element: unknown, index: number): Point | null {\n if (isFiniteNumber(element)) {\n return { x: index, y: element };\n }\n if (Array.isArray(element)) {\n const [a, b] = element;\n if (isFiniteNumber(a) && isFiniteNumber(b)) {\n return { x: a, y: b };\n }\n if (isFiniteNumber(a) && b === undefined) {\n return { x: index, y: a };\n }\n return null;\n }\n if (element && typeof element === 'object') {\n const obj = element as Record<string, unknown>;\n const yRaw = obj.y ?? obj.value ?? obj.val ?? obj.count;\n if (!isFiniteNumber(yRaw)) {\n return null;\n }\n const xRaw = obj.x ?? obj.t ?? obj.time ?? obj.index ?? obj.bin;\n return { x: isFiniteNumber(xRaw) ? xRaw : index, y: yRaw };\n }\n return null;\n}\n\n/** Map an array to points, dropping unparseable elements. */\nfunction pointsFrom(raw: unknown[]): Point[] {\n const points: Point[] = [];\n for (let i = 0; i < raw.length; i += 1) {\n const point = toPoint(raw[i], i);\n if (point) {\n points.push(point);\n }\n }\n return points;\n}\n\n/** Evenly downsample a long series so the SVG stays light on huge payloads. */\nfunction sample(points: Point[]): Point[] {\n if (points.length <= MAX_POINTS_PER_SERIES) {\n return points;\n }\n const stride = points.length / MAX_POINTS_PER_SERIES;\n const out: Point[] = [];\n for (let i = 0; i < MAX_POINTS_PER_SERIES; i += 1) {\n out.push(points[Math.floor(i * stride)]);\n }\n return out;\n}\n\nfunction kindFrom(raw: string): SeriesKind | undefined {\n if (/scatter|point|dot|observ|raw/i.test(raw)) {\n return 'scatter';\n }\n if (/line|fit|curve|model|trend|series/i.test(raw)) {\n return 'line';\n }\n return undefined;\n}\n\n/** Sniff the payload for one or more numeric series (empty = not chartable). */\nfunction extractSeries(results: Json): Series[] {\n const out: Series[] = [];\n let colorIndex = 0;\n const nextColor = (): string => {\n const color = SERIES_PALETTE[colorIndex % SERIES_PALETTE.length];\n colorIndex += 1;\n return color;\n };\n const push = (raw: unknown[], name: string, kind: SeriesKind): void => {\n const points = sample(pointsFrom(raw));\n if (points.length >= 2) {\n out.push({ name, kind, points, colorVar: nextColor() });\n }\n };\n\n // 1. Explicit `series` array — the richest shape.\n const series = results.series;\n if (Array.isArray(series)) {\n series.forEach((entry, i) => {\n if (Array.isArray(entry)) {\n push(entry, `Series ${i + 1}`, 'line');\n return;\n }\n if (entry && typeof entry === 'object') {\n const so = entry as Record<string, unknown>;\n const data = so.points ?? so.data ?? so.values;\n if (!Array.isArray(data)) {\n return;\n }\n const name =\n typeof so.name === 'string' && so.name.trim()\n ? so.name\n : typeof so.label === 'string' && so.label.trim()\n ? so.label\n : `Series ${i + 1}`;\n const kindRaw = [so.kind, so.type, so.name, so.label]\n .filter((v): v is string => typeof v === 'string')\n .join(' ');\n push(data, name, kindFrom(kindRaw) ?? 'line');\n }\n });\n }\n\n // 2. `points` (scatter) plus optional `fit` / `model` overlay line.\n if (out.length === 0) {\n if (Array.isArray(results.points)) {\n push(results.points, 'Observations', 'scatter');\n } else if (Array.isArray(results.data)) {\n push(results.data, 'Data', 'line');\n } else if (Array.isArray(results.values)) {\n push(results.values, 'Values', 'line');\n }\n if (Array.isArray(results.fit)) {\n push(results.fit, 'Fit', 'line');\n }\n if (Array.isArray(results.model)) {\n push(results.model, 'Model', 'line');\n }\n }\n\n // 3. Scan for the first few bare numeric arrays (e.g. { loss, accuracy }).\n if (out.length === 0) {\n for (const [key, value] of Object.entries(results)) {\n if (Array.isArray(value)) {\n push(value, humanize(key), 'line');\n }\n if (out.length >= SERIES_PALETTE.length) {\n break;\n }\n }\n }\n\n return out;\n}\n\nfunction readLabel(results: Json, keys: string[], axisKey: 'x' | 'y', fallback: string): string {\n for (const key of keys) {\n const value = results[key];\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n }\n const axes = results.axes ?? results.axis;\n if (axes && typeof axes === 'object') {\n const value = (axes as Record<string, unknown>)[axisKey];\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n }\n return fallback;\n}\n\n// ---------------------------------------------------------------------------\n// Axis math\n// ---------------------------------------------------------------------------\n\n/** Rounded, human-friendly tick values across [min, max]. */\nfunction niceTicks(min: number, max: number, count: number): number[] {\n if (!Number.isFinite(min) || !Number.isFinite(max) || min === max) {\n return [min];\n }\n const span = max - min;\n const rawStep = span / Math.max(1, count);\n const mag = Math.pow(10, Math.floor(Math.log10(rawStep)));\n const norm = rawStep / mag;\n const niceNorm = norm < 1.5 ? 1 : norm < 3 ? 2 : norm < 7 ? 5 : 10;\n const step = niceNorm * mag;\n const start = Math.floor(min / step) * step;\n const end = Math.ceil(max / step) * step;\n const ticks: number[] = [];\n for (let v = start; v <= end + step * 1e-6; v += step) {\n ticks.push(Number(v.toFixed(12)));\n }\n return ticks;\n}\n\nfunction formatTick(value: number): string {\n if (value === 0) {\n return '0';\n }\n const abs = Math.abs(value);\n if (abs < 1e-3 || abs >= 1e6) {\n return value.toExponential(1);\n }\n const rounded = Number(value.toPrecision(4));\n return rounded.toLocaleString(undefined, { maximumFractionDigits: 4 });\n}\n\n// ---------------------------------------------------------------------------\n// Chart geometry\n// ---------------------------------------------------------------------------\n\nconst VIEW_W = 640;\nconst VIEW_H = 340;\nconst MARGIN = { top: 16, right: 20, bottom: 48, left: 62 };\nconst INNER_W = VIEW_W - MARGIN.left - MARGIN.right;\nconst INNER_H = VIEW_H - MARGIN.top - MARGIN.bottom;\n\ninterface ChartModel {\n series: Series[];\n xTicks: number[];\n yTicks: number[];\n domainX: [number, number];\n domainY: [number, number];\n xLabel: string;\n yLabel: string;\n}\n\nfunction buildModel(results: Json): ChartModel | null {\n const series = extractSeries(results);\n if (series.length === 0) {\n return null;\n }\n\n const xs: number[] = [];\n const ys: number[] = [];\n for (const s of series) {\n for (const p of s.points) {\n xs.push(p.x);\n ys.push(p.y);\n }\n }\n\n let minX = Math.min(...xs);\n let maxX = Math.max(...xs);\n let minY = Math.min(...ys);\n let maxY = Math.max(...ys);\n\n if (minX === maxX) {\n const pad = Math.abs(minX) || 1;\n minX -= pad;\n maxX += pad;\n }\n if (minY === maxY) {\n const pad = Math.abs(minY) || 1;\n minY -= pad;\n maxY += pad;\n }\n // Breathing room above/below the data so markers are not clipped.\n const yPad = (maxY - minY) * 0.08;\n minY -= yPad;\n maxY += yPad;\n\n const xTicks = niceTicks(minX, maxX, 5);\n const yTicks = niceTicks(minY, maxY, 5);\n const domainX: [number, number] = [\n Math.min(minX, xTicks[0]),\n Math.max(maxX, xTicks[xTicks.length - 1]),\n ];\n const domainY: [number, number] = [\n Math.min(minY, yTicks[0]),\n Math.max(maxY, yTicks[yTicks.length - 1]),\n ];\n\n return {\n series,\n xTicks: xTicks.filter((t) => t >= domainX[0] && t <= domainX[1]),\n yTicks: yTicks.filter((t) => t >= domainY[0] && t <= domainY[1]),\n domainX,\n domainY,\n xLabel: readLabel(results, ['xLabel', 'xlabel', 'xAxis', 'xaxis', 'xTitle', 'xUnit'], 'x', 'x'),\n yLabel: readLabel(results, ['yLabel', 'ylabel', 'yAxis', 'yaxis', 'yTitle', 'yUnit'], 'y', 'y'),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Fallback key/value table\n// ---------------------------------------------------------------------------\n\nfunction displayValue(value: unknown): string {\n if (value === null || value === undefined) {\n return '—';\n }\n if (typeof value === 'number') {\n return value.toLocaleString(undefined, { maximumFractionDigits: 6 });\n }\n if (typeof value === 'boolean') {\n return value ? 'Yes' : 'No';\n }\n if (typeof value === 'string') {\n return value;\n }\n if (Array.isArray(value)) {\n return `${value.length} item${value.length === 1 ? '' : 's'}`;\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction MetricsTable({ results }: { results: Json }) {\n const entries = Object.entries(results);\n if (entries.length === 0) {\n return (\n <p className=\"rounded-card border border-border-default bg-bg-sunken px-4 py-6 text-center text-sm text-text-secondary\">\n No structured results were recorded for this analysis.\n </p>\n );\n }\n return (\n <dl className=\"grid grid-cols-1 gap-px overflow-hidden rounded-card border border-border-default bg-border-subtle sm:grid-cols-2\">\n {entries.map(([key, value]) => {\n const text = displayValue(value);\n return (\n <div\n key={key}\n className=\"flex items-baseline justify-between gap-3 bg-bg-elevated px-3 py-2\"\n >\n <dt className=\"min-w-0 truncate text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {humanize(key)}\n </dt>\n <dd\n className=\"max-w-[60%] truncate text-right text-sm tabular-nums text-text-primary\"\n title={text}\n >\n {text}\n </dd>\n </div>\n );\n })}\n </dl>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport interface ResultsChartProps {\n results: Record<string, unknown>;\n className?: string;\n}\n\nexport function ResultsChart({ results, className }: ResultsChartProps) {\n const model = useMemo(() => buildModel(results), [results]);\n\n if (!model) {\n return (\n <div className={className}>\n <MetricsTable results={results} />\n </div>\n );\n }\n\n const { series, xTicks, yTicks, domainX, domainY, xLabel, yLabel } = model;\n\n const sx = (x: number): number =>\n MARGIN.left + ((x - domainX[0]) / (domainX[1] - domainX[0])) * INNER_W;\n const sy = (y: number): number =>\n MARGIN.top + INNER_H - ((y - domainY[0]) / (domainY[1] - domainY[0])) * INNER_H;\n\n const showLegend = series.length > 1;\n const ariaLabel = `Chart of ${series\n .map((s) => s.name)\n .join(', ')}; x-axis ${xLabel}, y-axis ${yLabel}`;\n\n return (\n <div className={cn('space-y-3', className)}>\n <div className=\"rounded-card border border-border-default bg-bg-sunken p-3\">\n <svg\n viewBox={`0 0 ${VIEW_W} ${VIEW_H}`}\n className=\"h-auto w-full\"\n preserveAspectRatio=\"xMidYMid meet\"\n role=\"img\"\n aria-label={ariaLabel}\n >\n {/* horizontal gridlines + y tick labels */}\n {yTicks.map((tick) => {\n const y = sy(tick);\n return (\n <g key={`y-${tick}`}>\n <line\n x1={MARGIN.left}\n x2={MARGIN.left + INNER_W}\n y1={y}\n y2={y}\n stroke=\"var(--color-chart-grid)\"\n strokeWidth={1}\n />\n <text\n x={MARGIN.left - 8}\n y={y}\n textAnchor=\"end\"\n dominantBaseline=\"central\"\n fontSize={11}\n fill=\"var(--color-text-tertiary)\"\n >\n {formatTick(tick)}\n </text>\n </g>\n );\n })}\n\n {/* vertical gridlines + x tick labels */}\n {xTicks.map((tick) => {\n const x = sx(tick);\n return (\n <g key={`x-${tick}`}>\n <line\n x1={x}\n x2={x}\n y1={MARGIN.top}\n y2={MARGIN.top + INNER_H}\n stroke=\"var(--color-chart-grid)\"\n strokeWidth={1}\n strokeDasharray=\"2 4\"\n />\n <text\n x={x}\n y={MARGIN.top + INNER_H + 18}\n textAnchor=\"middle\"\n fontSize={11}\n fill=\"var(--color-text-tertiary)\"\n >\n {formatTick(tick)}\n </text>\n </g>\n );\n })}\n\n {/* plot frame */}\n <rect\n x={MARGIN.left}\n y={MARGIN.top}\n width={INNER_W}\n height={INNER_H}\n fill=\"none\"\n stroke=\"var(--color-chart-axis)\"\n strokeWidth={1}\n />\n\n {/* series */}\n {series.map((s) => {\n const ordered = [...s.points].sort((a, b) => a.x - b.x);\n const path = ordered\n .map((p, i) => `${i === 0 ? 'M' : 'L'} ${sx(p.x).toFixed(2)} ${sy(p.y).toFixed(2)}`)\n .join(' ');\n const showDots = s.kind === 'scatter' || s.points.length <= 40;\n return (\n <g key={s.name}>\n {s.kind === 'line' ? (\n <path\n d={path}\n fill=\"none\"\n stroke={s.colorVar}\n strokeWidth={2}\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n ) : null}\n {showDots\n ? s.points.map((p, i) => (\n <circle\n key={`${s.name}-${i}`}\n cx={sx(p.x)}\n cy={sy(p.y)}\n r={s.kind === 'scatter' ? 2.4 : 2.8}\n fill={s.colorVar}\n fillOpacity={s.kind === 'scatter' ? 0.85 : 1}\n />\n ))\n : null}\n </g>\n );\n })}\n\n {/* axis titles */}\n <text\n x={MARGIN.left + INNER_W / 2}\n y={VIEW_H - 6}\n textAnchor=\"middle\"\n fontSize={12}\n fill=\"var(--color-text-secondary)\"\n >\n {xLabel}\n </text>\n <text\n x={14}\n y={MARGIN.top + INNER_H / 2}\n textAnchor=\"middle\"\n fontSize={12}\n fill=\"var(--color-text-secondary)\"\n transform={`rotate(-90 14 ${MARGIN.top + INNER_H / 2})`}\n >\n {yLabel}\n </text>\n </svg>\n </div>\n\n {showLegend ? (\n <ul className=\"flex flex-wrap gap-x-4 gap-y-1.5\">\n {series.map((s) => (\n <li key={s.name} className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block size-2.5 rounded-full\"\n style={{ backgroundColor: s.colorVar }}\n />\n <span className=\"truncate\">\n {s.name}\n <span className=\"ml-1 text-text-tertiary\">\n ({s.kind === 'scatter' ? 'points' : 'line'})\n </span>\n </span>\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n}\n\nexport default ResultsChart;\n"],"mappings":";;;;AA0CA,IAAM,IAAiB;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC,EAAE,KAAK,MAAM,qBAAqB,EAAE,EAAE,GAExE,IAAwB;AAM9B,SAAS,EAAe,GAAiC;CACvD,OAAO,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK;AAC3D;AAEA,SAAS,EAAS,GAAqB;CACrC,IAAM,IAAS,EACZ,QAAQ,UAAU,GAAG,EACrB,QAAQ,sBAAsB,OAAO,EACrC,KAAK;CAIR,OAHK,IAGE,EAAO,OAAO,CAAC,EAAE,YAAY,IAAI,EAAO,MAAM,CAAC,IAF7C;AAGX;AAGA,SAAS,EAAQ,GAAkB,GAA6B;CAC9D,IAAI,EAAe,CAAO,GACxB,OAAO;EAAE,GAAG;EAAO,GAAG;CAAQ;CAEhC,IAAI,MAAM,QAAQ,CAAO,GAAG;EAC1B,IAAM,CAAC,GAAG,KAAK;EAOf,OANI,EAAe,CAAC,KAAK,EAAe,CAAC,IAChC;G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L,WAAW,iBAAiB,EAAO,MAAM,IAAU,EAAE;gBAEpD;KACG,CAAA;IACH;;EACF,CAAA,GAEJ,IACC,kBAAC,MAAD;GAAI,WAAU;aACX,EAAO,KAAK,MACX,kBAAC,MAAD;IAAiB,WAAU;cAA3B,CACE,kBAAC,QAAD;KACE,eAAY;KACZ,WAAU;KACV,OAAO,EAAE,iBAAiB,EAAE,SAAS;IACtC,CAAA,GACD,kBAAC,QAAD;KAAM,WAAU;eAAhB,CACG,EAAE,MACH,kBAAC,QAAD;MAAM,WAAU;gBAAhB;OAA0C;OACtC,EAAE,SAAS,YAAY,WAAW;OAAO;MACvC;OACF;MACJ;MAZK,EAAE,IAYP,CACL;EACC,CAAA,IACF,IACD;;AAET"}
|
|
1
|
+
{"version":3,"file":"ResultsChart.js","names":[],"sources":["../../../src/cosmicintersection/components/ResultsChart.tsx"],"sourcesContent":["/**\n * ResultsChart — inline visualization for a completed analysis' `results` JSON.\n *\n * There is NO chart library here: axes, gridlines, scatter dots and line series\n * are hand-drawn as SVG using the design system's dataviz tokens\n * (`var(--color-chart-*)`, `var(--color-chart-axis)`, `var(--color-chart-grid)`)\n * plus the standard text tokens — never a raw palette colour. The SVG uses a\n * `viewBox` and `width:100%`, so it scales fluidly on phones (no horizontal\n * scroll).\n *\n * The `results` payload is free-form JSON (whatever `cosCompleteAnalysis` stored),\n * so the component sniffs it for numeric series. Accepted shapes:\n * - `results.series: Array<{ name?, kind?: 'line'|'scatter', points }>`\n * - `results.points` (scatter) and/or `results.fit` / `results.model` (line)\n * - any top-level numeric arrays (rendered as line series)\n * where a `points` array may hold `{x,y}` objects, `[x,y]` pairs, `{value}` /\n * `{y}` objects, or bare numbers (index used as x).\n *\n * When nothing chartable is found, a compact, responsive key/value metrics list\n * is rendered instead. Everything comes from the real payload — nothing is\n * fabricated; an empty payload renders an honest \"no results\" message.\n */\nimport { useMemo } from 'react';\n\nimport { cn } from '../utils/cn';\n\ntype Json = Record<string, unknown>;\n\ninterface Point {\n x: number;\n y: number;\n}\n\ntype SeriesKind = 'line' | 'scatter';\n\ninterface Series {\n name: string;\n kind: SeriesKind;\n points: Point[];\n colorVar: string;\n}\n\nconst SERIES_PALETTE = [1, 2, 3, 4, 5, 6].map((n) => `var(--color-chart-${n})`);\n\nconst MAX_POINTS_PER_SERIES = 600;\n\n// ---------------------------------------------------------------------------\n// Payload parsing\n// ---------------------------------------------------------------------------\n\nfunction isFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value);\n}\n\nfunction humanize(key: string): string {\n const spaced = key\n .replace(/[_-]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .trim();\n if (!spaced) {\n return key;\n }\n return spaced.charAt(0).toUpperCase() + spaced.slice(1);\n}\n\n/** Coerce a single raw element into a {x,y} point (index is the fallback x). */\nfunction toPoint(element: unknown, index: number): Point | null {\n if (isFiniteNumber(element)) {\n return { x: index, y: element };\n }\n if (Array.isArray(element)) {\n const [a, b] = element;\n if (isFiniteNumber(a) && isFiniteNumber(b)) {\n return { x: a, y: b };\n }\n if (isFiniteNumber(a) && b === undefined) {\n return { x: index, y: a };\n }\n return null;\n }\n if (element && typeof element === 'object') {\n const obj = element as Record<string, unknown>;\n const yRaw = obj.y ?? obj.value ?? obj.val ?? obj.count;\n if (!isFiniteNumber(yRaw)) {\n return null;\n }\n const xRaw = obj.x ?? obj.t ?? obj.time ?? obj.index ?? obj.bin;\n return { x: isFiniteNumber(xRaw) ? xRaw : index, y: yRaw };\n }\n return null;\n}\n\n/** Map an array to points, dropping unparseable elements. */\nfunction pointsFrom(raw: unknown[]): Point[] {\n const points: Point[] = [];\n for (let i = 0; i < raw.length; i += 1) {\n const point = toPoint(raw[i], i);\n if (point) {\n points.push(point);\n }\n }\n return points;\n}\n\n/** Evenly downsample a long series so the SVG stays light on huge payloads. */\nfunction sample(points: Point[]): Point[] {\n if (points.length <= MAX_POINTS_PER_SERIES) {\n return points;\n }\n const stride = points.length / MAX_POINTS_PER_SERIES;\n const out: Point[] = [];\n for (let i = 0; i < MAX_POINTS_PER_SERIES; i += 1) {\n out.push(points[Math.floor(i * stride)]);\n }\n return out;\n}\n\nfunction kindFrom(raw: string): SeriesKind | undefined {\n if (/scatter|point|dot|observ|raw/i.test(raw)) {\n return 'scatter';\n }\n if (/line|fit|curve|model|trend|series/i.test(raw)) {\n return 'line';\n }\n return undefined;\n}\n\n/** Sniff the payload for one or more numeric series (empty = not chartable). */\nfunction extractSeries(results: Json): Series[] {\n const out: Series[] = [];\n let colorIndex = 0;\n const nextColor = (): string => {\n const color = SERIES_PALETTE[colorIndex % SERIES_PALETTE.length];\n colorIndex += 1;\n return color;\n };\n const push = (raw: unknown[], name: string, kind: SeriesKind): void => {\n const points = sample(pointsFrom(raw));\n if (points.length >= 2) {\n out.push({ name, kind, points, colorVar: nextColor() });\n }\n };\n\n // 1. Explicit `series` array — the richest shape.\n const series = results.series;\n if (Array.isArray(series)) {\n series.forEach((entry, i) => {\n if (Array.isArray(entry)) {\n push(entry, `Series ${i + 1}`, 'line');\n return;\n }\n if (entry && typeof entry === 'object') {\n const so = entry as Record<string, unknown>;\n const data = so.points ?? so.data ?? so.values;\n if (!Array.isArray(data)) {\n return;\n }\n const name =\n typeof so.name === 'string' && so.name.trim()\n ? so.name\n : typeof so.label === 'string' && so.label.trim()\n ? so.label\n : `Series ${i + 1}`;\n const kindRaw = [so.kind, so.type, so.name, so.label]\n .filter((v): v is string => typeof v === 'string')\n .join(' ');\n push(data, name, kindFrom(kindRaw) ?? 'line');\n }\n });\n }\n\n // 2. `points` (scatter) plus optional `fit` / `model` overlay line.\n if (out.length === 0) {\n if (Array.isArray(results.points)) {\n push(results.points, 'Observations', 'scatter');\n } else if (Array.isArray(results.data)) {\n push(results.data, 'Data', 'line');\n } else if (Array.isArray(results.values)) {\n push(results.values, 'Values', 'line');\n }\n if (Array.isArray(results.fit)) {\n push(results.fit, 'Fit', 'line');\n }\n if (Array.isArray(results.model)) {\n push(results.model, 'Model', 'line');\n }\n }\n\n // 3. Scan for the first few bare numeric arrays (e.g. { loss, accuracy }).\n if (out.length === 0) {\n for (const [key, value] of Object.entries(results)) {\n if (Array.isArray(value)) {\n push(value, humanize(key), 'line');\n }\n if (out.length >= SERIES_PALETTE.length) {\n break;\n }\n }\n }\n\n return out;\n}\n\nfunction readLabel(results: Json, keys: string[], axisKey: 'x' | 'y', fallback: string): string {\n for (const key of keys) {\n const value = results[key];\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n }\n const axes = results.axes ?? results.axis;\n if (axes && typeof axes === 'object') {\n const value = (axes as Record<string, unknown>)[axisKey];\n if (typeof value === 'string' && value.trim()) {\n return value;\n }\n }\n return fallback;\n}\n\n// ---------------------------------------------------------------------------\n// Axis math\n// ---------------------------------------------------------------------------\n\n/** Rounded, human-friendly tick values across [min, max]. */\nfunction niceTicks(min: number, max: number, count: number): number[] {\n if (!Number.isFinite(min) || !Number.isFinite(max) || min === max) {\n return [min];\n }\n const span = max - min;\n const rawStep = span / Math.max(1, count);\n const mag = Math.pow(10, Math.floor(Math.log10(rawStep)));\n const norm = rawStep / mag;\n const niceNorm = norm < 1.5 ? 1 : norm < 3 ? 2 : norm < 7 ? 5 : 10;\n const step = niceNorm * mag;\n const start = Math.floor(min / step) * step;\n const end = Math.ceil(max / step) * step;\n const ticks: number[] = [];\n for (let v = start; v <= end + step * 1e-6; v += step) {\n ticks.push(Number(v.toFixed(12)));\n }\n return ticks;\n}\n\nfunction formatTick(value: number): string {\n if (value === 0) {\n return '0';\n }\n const abs = Math.abs(value);\n if (abs < 1e-3 || abs >= 1e6) {\n return value.toExponential(1);\n }\n const rounded = Number(value.toPrecision(4));\n return rounded.toLocaleString(undefined, { maximumFractionDigits: 4 });\n}\n\n// ---------------------------------------------------------------------------\n// Chart geometry\n// ---------------------------------------------------------------------------\n\nconst VIEW_W = 640;\nconst VIEW_H = 340;\nconst MARGIN = { top: 16, right: 20, bottom: 48, left: 62 };\nconst INNER_W = VIEW_W - MARGIN.left - MARGIN.right;\nconst INNER_H = VIEW_H - MARGIN.top - MARGIN.bottom;\n\ninterface ChartModel {\n series: Series[];\n xTicks: number[];\n yTicks: number[];\n domainX: [number, number];\n domainY: [number, number];\n xLabel: string;\n yLabel: string;\n}\n\nfunction buildModel(results: Json): ChartModel | null {\n const series = extractSeries(results);\n if (series.length === 0) {\n return null;\n }\n\n const xs: number[] = [];\n const ys: number[] = [];\n for (const s of series) {\n for (const p of s.points) {\n xs.push(p.x);\n ys.push(p.y);\n }\n }\n\n let minX = Math.min(...xs);\n let maxX = Math.max(...xs);\n let minY = Math.min(...ys);\n let maxY = Math.max(...ys);\n\n if (minX === maxX) {\n const pad = Math.abs(minX) || 1;\n minX -= pad;\n maxX += pad;\n }\n if (minY === maxY) {\n const pad = Math.abs(minY) || 1;\n minY -= pad;\n maxY += pad;\n }\n // Breathing room above/below the data so markers are not clipped.\n const yPad = (maxY - minY) * 0.08;\n minY -= yPad;\n maxY += yPad;\n\n const xTicks = niceTicks(minX, maxX, 5);\n const yTicks = niceTicks(minY, maxY, 5);\n const domainX: [number, number] = [\n Math.min(minX, xTicks[0]),\n Math.max(maxX, xTicks[xTicks.length - 1]),\n ];\n const domainY: [number, number] = [\n Math.min(minY, yTicks[0]),\n Math.max(maxY, yTicks[yTicks.length - 1]),\n ];\n\n return {\n series,\n xTicks: xTicks.filter((t) => t >= domainX[0] && t <= domainX[1]),\n yTicks: yTicks.filter((t) => t >= domainY[0] && t <= domainY[1]),\n domainX,\n domainY,\n xLabel: readLabel(results, ['xLabel', 'xlabel', 'xAxis', 'xaxis', 'xTitle', 'xUnit'], 'x', 'x'),\n yLabel: readLabel(results, ['yLabel', 'ylabel', 'yAxis', 'yaxis', 'yTitle', 'yUnit'], 'y', 'y'),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Fallback key/value table\n// ---------------------------------------------------------------------------\n\nfunction displayValue(value: unknown): string {\n if (value === null || value === undefined) {\n return '—';\n }\n if (typeof value === 'number') {\n return value.toLocaleString(undefined, { maximumFractionDigits: 6 });\n }\n if (typeof value === 'boolean') {\n return value ? 'Yes' : 'No';\n }\n if (typeof value === 'string') {\n return value;\n }\n if (Array.isArray(value)) {\n return `${value.length} item${value.length === 1 ? '' : 's'}`;\n }\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n}\n\nfunction MetricsTable({ results }: { results: Json }) {\n const entries = Object.entries(results);\n if (entries.length === 0) {\n return (\n <p className=\"rounded-card border border-border-default bg-bg-sunken px-4 py-6 text-center text-sm text-text-secondary\">\n No structured results were recorded for this analysis.\n </p>\n );\n }\n return (\n <dl className=\"grid grid-cols-1 gap-px overflow-hidden rounded-card border border-border-default bg-border-subtle sm:grid-cols-2\">\n {entries.map(([key, value]) => {\n const text = displayValue(value);\n return (\n <div\n key={key}\n className=\"flex items-baseline justify-between gap-3 bg-bg-elevated px-3 py-2\"\n >\n <dt className=\"min-w-0 truncate text-xs font-medium uppercase tracking-wide text-text-secondary\">\n {humanize(key)}\n </dt>\n <dd\n className=\"max-w-[60%] truncate text-right text-sm tabular-nums text-text-primary\"\n title={text}\n >\n {text}\n </dd>\n </div>\n );\n })}\n </dl>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport interface ResultsChartProps {\n results: Record<string, unknown>;\n className?: string;\n}\n\nexport function ResultsChart({ results, className }: ResultsChartProps) {\n const model = useMemo(() => buildModel(results), [results]);\n\n if (!model) {\n return (\n <div className={className}>\n <MetricsTable results={results} />\n </div>\n );\n }\n\n const { series, xTicks, yTicks, domainX, domainY, xLabel, yLabel } = model;\n\n const sx = (x: number): number =>\n MARGIN.left + ((x - domainX[0]) / (domainX[1] - domainX[0])) * INNER_W;\n const sy = (y: number): number =>\n MARGIN.top + INNER_H - ((y - domainY[0]) / (domainY[1] - domainY[0])) * INNER_H;\n\n const showLegend = series.length > 1;\n const ariaLabel = `Chart of ${series\n .map((s) => s.name)\n .join(', ')}; x-axis ${xLabel}, y-axis ${yLabel}`;\n\n return (\n <div className={cn('space-y-3', className)}>\n <div className=\"rounded-card border border-border-default bg-bg-sunken p-3\">\n <svg\n viewBox={`0 0 ${VIEW_W} ${VIEW_H}`}\n className=\"h-auto w-full\"\n preserveAspectRatio=\"xMidYMid meet\"\n role=\"img\"\n aria-label={ariaLabel}\n >\n {/* horizontal gridlines + y tick labels */}\n {yTicks.map((tick) => {\n const y = sy(tick);\n return (\n <g key={`y-${tick}`}>\n <line\n x1={MARGIN.left}\n x2={MARGIN.left + INNER_W}\n y1={y}\n y2={y}\n stroke=\"var(--color-chart-grid)\"\n strokeWidth={1}\n />\n <text\n x={MARGIN.left - 8}\n y={y}\n textAnchor=\"end\"\n dominantBaseline=\"central\"\n fontSize={11}\n fill=\"var(--color-text-tertiary)\"\n >\n {formatTick(tick)}\n </text>\n </g>\n );\n })}\n\n {/* vertical gridlines + x tick labels */}\n {xTicks.map((tick) => {\n const x = sx(tick);\n return (\n <g key={`x-${tick}`}>\n <line\n x1={x}\n x2={x}\n y1={MARGIN.top}\n y2={MARGIN.top + INNER_H}\n stroke=\"var(--color-chart-grid)\"\n strokeWidth={1}\n strokeDasharray=\"2 4\"\n />\n <text\n x={x}\n y={MARGIN.top + INNER_H + 18}\n textAnchor=\"middle\"\n fontSize={11}\n fill=\"var(--color-text-tertiary)\"\n >\n {formatTick(tick)}\n </text>\n </g>\n );\n })}\n\n {/* plot frame */}\n <rect\n x={MARGIN.left}\n y={MARGIN.top}\n width={INNER_W}\n height={INNER_H}\n fill=\"none\"\n stroke=\"var(--color-chart-axis)\"\n strokeWidth={1}\n />\n\n {/* series */}\n {series.map((s) => {\n const ordered = [...s.points].sort((a, b) => a.x - b.x);\n const path = ordered\n .map((p, i) => `${i === 0 ? 'M' : 'L'} ${sx(p.x).toFixed(2)} ${sy(p.y).toFixed(2)}`)\n .join(' ');\n const showDots = s.kind === 'scatter' || s.points.length <= 40;\n return (\n <g key={s.name}>\n {s.kind === 'line' ? (\n <path\n d={path}\n fill=\"none\"\n stroke={s.colorVar}\n strokeWidth={2}\n strokeLinejoin=\"round\"\n strokeLinecap=\"round\"\n />\n ) : null}\n {showDots\n ? s.points.map((p, i) => (\n <circle\n key={`${s.name}-${i}`}\n cx={sx(p.x)}\n cy={sy(p.y)}\n r={s.kind === 'scatter' ? 2.4 : 2.8}\n fill={s.colorVar}\n fillOpacity={s.kind === 'scatter' ? 0.85 : 1}\n />\n ))\n : null}\n </g>\n );\n })}\n\n {/* axis titles */}\n <text\n x={MARGIN.left + INNER_W / 2}\n y={VIEW_H - 6}\n textAnchor=\"middle\"\n fontSize={12}\n fill=\"var(--color-text-secondary)\"\n >\n {xLabel}\n </text>\n <text\n x={14}\n y={MARGIN.top + INNER_H / 2}\n textAnchor=\"middle\"\n fontSize={12}\n fill=\"var(--color-text-secondary)\"\n transform={`rotate(-90 14 ${MARGIN.top + INNER_H / 2})`}\n >\n {yLabel}\n </text>\n </svg>\n </div>\n\n {showLegend ? (\n <ul className=\"flex flex-wrap gap-x-4 gap-y-1.5\">\n {series.map((s) => (\n <li key={s.name} className=\"flex items-center gap-1.5 text-xs text-text-secondary\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block size-2.5 rounded-full\"\n style={{ backgroundColor: s.colorVar }}\n />\n <span className=\"truncate\">\n {s.name}\n <span className=\"ml-1 text-text-tertiary\">\n ({s.kind === 'scatter' ? 'points' : 'line'})\n </span>\n </span>\n </li>\n ))}\n </ul>\n ) : null}\n </div>\n );\n}\n\nexport default ResultsChart;\n"],"mappings":";;;;AA0CA,IAAM,IAAiB;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC,CAAC,CAAC,KAAK,MAAM,qBAAqB,EAAE,EAAE,GAExE,IAAwB;AAM9B,SAAS,EAAe,GAAiC;CACvD,OAAO,OAAO,KAAU,YAAY,OAAO,SAAS,CAAK;AAC3D;AAEA,SAAS,EAAS,GAAqB;CACrC,IAAM,IAAS,EACZ,QAAQ,UAAU,GAAG,CAAC,CACtB,QAAQ,sB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V,IAAI,EAAG,EAAE,CAAC;OACV,GAAG,EAAE,SAAS,YAAY,MAAM;OAChC,MAAM,EAAE;OACR,aAAa,EAAE,SAAS,YAAY,MAAO;MAC5C,GANM,GAAG,EAAE,KAAK,GAAG,GAMnB,CACF,IACD,IACH,EAAA,GAvBK,EAAE,IAuBP;KAEP,CAAC;KAGD,kBAAC,QAAD;MACE,GAAG,EAAO,OAAO,IAAU;MAC3B,GAAG,IAAS;MACZ,YAAW;MACX,UAAU;MACV,MAAK;gBAEJ;KACG,CAAA;KACN,kBAAC,QAAD;MACE,GAAG;MACH,GAAG,EAAO,MAAM,IAAU;MAC1B,YAAW;MACX,UAAU;MACV,MAAK;MACL,WAAW,iBAAiB,EAAO,MAAM,IAAU,EAAE;gBAEpD;KACG,CAAA;IACH;;EACF,CAAA,GAEJ,IACC,kBAAC,MAAD;GAAI,WAAU;aACX,EAAO,KAAK,MACX,kBAAC,MAAD;IAAiB,WAAU;cAA3B,CACE,kBAAC,QAAD;KACE,eAAY;KACZ,WAAU;KACV,OAAO,EAAE,iBAAiB,EAAE,SAAS;IACtC,CAAA,GACD,kBAAC,QAAD;KAAM,WAAU;eAAhB,CACG,EAAE,MACH,kBAAC,QAAD;MAAM,WAAU;gBAAhB;OAA0C;OACtC,EAAE,SAAS,YAAY,WAAW;OAAO;MACvC;OACF;MACJ;MAZK,EAAE,IAYP,CACL;EACC,CAAA,IACF,IACD;;AAET"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnchorHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* Validate and normalise a user-supplied URL before it is ever placed in an
|
|
5
4
|
* `href`. Free-text URL fields (source endpoints, external references) are
|
|
@@ -30,6 +29,6 @@ export interface SafeLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorEleme
|
|
|
30
29
|
* can never be activated. External links open in a new tab with
|
|
31
30
|
* `noopener noreferrer`; root-relative in-app links open in the same tab.
|
|
32
31
|
*/
|
|
33
|
-
export declare function SafeLink({ href, children, className, fallbackClassName, ...rest }: SafeLinkProps): import(
|
|
32
|
+
export declare function SafeLink({ href, children, className, fallbackClassName, ...rest }: SafeLinkProps): import('react').JSX.Element;
|
|
34
33
|
export default SafeLink;
|
|
35
34
|
//# sourceMappingURL=SafeLink.d.ts.map
|
|
@@ -18,6 +18,6 @@ export interface StatusBadgeProps {
|
|
|
18
18
|
label?: string;
|
|
19
19
|
className?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare function StatusBadge({ status, tone, label, className }: StatusBadgeProps): import(
|
|
21
|
+
export declare function StatusBadge({ status, tone, label, className }: StatusBadgeProps): import('react').JSX.Element;
|
|
22
22
|
export default StatusBadge;
|
|
23
23
|
//# sourceMappingURL=StatusBadge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/cosmicintersection/components/StatusBadge.tsx"],"sourcesContent":["import { useTr } from '../../shared/hooks/useTr';\n\n/**\n * StatusBadge — maps the Cos* enum values to the semantic status token families.\n *\n * One badge component covers every CosmicIntersection enum (dataset/source/\n * pipeline/run/step/notebook/analysis/release/grant status, plus access level).\n * Colour comes only from the `status-{success,info,warning,error,neutral}`\n * token families — never a raw palette colour — so it renders correctly in every\n * theme.\n */\n\nexport type StatusTone = 'success' | 'info' | 'warning' | 'error' | 'neutral';\n\nconst TONE_CLASS: Record<StatusTone, string> = {\n success: 'bg-status-success-bg-subtle text-status-success-text border-status-success-border',\n info: 'bg-status-info-bg-subtle text-status-info-text border-status-info-border',\n warning: 'bg-status-warning-bg-subtle text-status-warning-text border-status-warning-border',\n error: 'bg-status-error-bg-subtle text-status-error-text border-status-error-border',\n neutral: 'bg-status-neutral-bg-subtle text-status-neutral-text border-status-neutral-border',\n};\n\n// Every Cos* enum value → tone. Values are unique enough across enums that a\n// single map is unambiguous; unknown values fall back to neutral.\nconst STATUS_TONE: Record<string, StatusTone> = {\n // healthy / terminal-good\n AVAILABLE: 'success',\n CONNECTED: 'success',\n SUCCEEDED: 'success',\n COMPLETED: 'success',\n PUBLISHED: 'success',\n ACTIVE: 'success',\n PUBLIC: 'success',\n // in-flight / attention\n INGESTING: 'warning',\n SYNCING: 'warning',\n RUNNING: 'warning',\n DEGRADED: 'warning',\n PAUSED: 'warning',\n DEPRECATED: 'warning',\n EXPIRED: 'warning',\n EMBARGOED: 'warning',\n RESTRICTED: 'warning',\n UNDER_REVIEW: 'warning',\n // queued / neutral-info\n DRAFT: 'info',\n CONFIGURING: 'info',\n QUEUED: 'info',\n PENDING: 'info',\n WORKSPACE: 'info',\n // failed / removed\n ERROR: 'error',\n FAILED: 'error',\n CANCELLED: 'error',\n RETRACTED: 'error',\n REVOKED: 'error',\n DISABLED: 'error',\n // archived / inert\n ARCHIVED: 'neutral',\n};\n\n/** Turn an ENUM_VALUE into a human label, e.g. GROUND_SENSOR -> \"Ground sensor\". */\nexport function formatEnumLabel(value: string): string {\n const lower = value.replace(/_/g, ' ').toLowerCase();\n return lower.charAt(0).toUpperCase() + lower.slice(1);\n}\n\n/** Known Cos* enum values → translation keys under `cosmicintersection.status`. */\nconst STATUS_LABEL_KEYS: Record<string, string> = {\n DRAFT: 'cosmicintersection.status.draft',\n ACTIVE: 'cosmicintersection.status.active',\n ARCHIVED: 'cosmicintersection.status.archived',\n ERROR: 'cosmicintersection.status.error',\n PENDING: 'cosmicintersection.status.pending',\n RUNNING: 'cosmicintersection.status.running',\n SUCCEEDED: 'cosmicintersection.status.succeeded',\n // COMPLETED (analyses) and PUBLISHED (releases) share the success tone with\n // SUCCEEDED but must keep their own wording: a published release labelled\n // \"Succeeded\" contradicts the \"Published\" status filter on the same page.\n COMPLETED: 'cosmicintersection.status.completed',\n PUBLISHED: 'cosmicintersection.status.published',\n FAILED: 'cosmicintersection.status.failed',\n CANCELLED: 'cosmicintersection.status.cancelled',\n PAUSED: 'cosmicintersection.status.paused',\n DISABLED: 'cosmicintersection.status.disabled',\n ENABLED: 'cosmicintersection.status.enabled',\n PUBLIC: 'cosmicintersection.status.public',\n PRIVATE: 'cosmicintersection.status.private',\n RESTRICTED: 'cosmicintersection.status.restricted',\n};\n\nexport interface StatusBadgeProps {\n status: string;\n /** Override the derived tone (e.g. to force a colour for a domain-specific case). */\n tone?: StatusTone;\n /** Override the rendered label; defaults to a title-cased enum value. */\n label?: string;\n className?: string;\n}\n\nexport function StatusBadge({ status, tone, label, className }: StatusBadgeProps) {\n const tr = useTr();\n const resolvedTone: StatusTone = tone ?? STATUS_TONE[status] ?? 'neutral';\n const fallbackLabel = formatEnumLabel(status);\n const translatedLabel =\n label ??\n (STATUS_LABEL_KEYS[status] ? tr(STATUS_LABEL_KEYS[status], fallbackLabel) : fallbackLabel);\n return (\n <span\n className={`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${TONE_CLASS[resolvedTone]} ${className ?? ''}`}\n >\n {translatedLabel}\n </span>\n );\n}\n\nexport default StatusBadge;\n"],"mappings":";;;AAcA,IAAM,IAAyC;CAC7C,SAAS;CACT,MAAM;CACN,SAAS;CACT,OAAO;CACP,SAAS;AACX,GAIM,IAA0C;CAE9C,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,QAAQ;CACR,QAAQ;CAER,WAAW;CACX,SAAS;CACT,SAAS;CACT,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,WAAW;CACX,YAAY;CACZ,cAAc;CAEd,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;CACT,WAAW;CAEX,OAAO;CACP,QAAQ;CACR,WAAW;CACX,WAAW;CACX,SAAS;CACT,UAAU;CAEV,UAAU;AACZ;AAGA,SAAgB,EAAgB,GAAuB;CACrD,IAAM,IAAQ,EAAM,QAAQ,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"StatusBadge.js","names":[],"sources":["../../../src/cosmicintersection/components/StatusBadge.tsx"],"sourcesContent":["import { useTr } from '../../shared/hooks/useTr';\n\n/**\n * StatusBadge — maps the Cos* enum values to the semantic status token families.\n *\n * One badge component covers every CosmicIntersection enum (dataset/source/\n * pipeline/run/step/notebook/analysis/release/grant status, plus access level).\n * Colour comes only from the `status-{success,info,warning,error,neutral}`\n * token families — never a raw palette colour — so it renders correctly in every\n * theme.\n */\n\nexport type StatusTone = 'success' | 'info' | 'warning' | 'error' | 'neutral';\n\nconst TONE_CLASS: Record<StatusTone, string> = {\n success: 'bg-status-success-bg-subtle text-status-success-text border-status-success-border',\n info: 'bg-status-info-bg-subtle text-status-info-text border-status-info-border',\n warning: 'bg-status-warning-bg-subtle text-status-warning-text border-status-warning-border',\n error: 'bg-status-error-bg-subtle text-status-error-text border-status-error-border',\n neutral: 'bg-status-neutral-bg-subtle text-status-neutral-text border-status-neutral-border',\n};\n\n// Every Cos* enum value → tone. Values are unique enough across enums that a\n// single map is unambiguous; unknown values fall back to neutral.\nconst STATUS_TONE: Record<string, StatusTone> = {\n // healthy / terminal-good\n AVAILABLE: 'success',\n CONNECTED: 'success',\n SUCCEEDED: 'success',\n COMPLETED: 'success',\n PUBLISHED: 'success',\n ACTIVE: 'success',\n PUBLIC: 'success',\n // in-flight / attention\n INGESTING: 'warning',\n SYNCING: 'warning',\n RUNNING: 'warning',\n DEGRADED: 'warning',\n PAUSED: 'warning',\n DEPRECATED: 'warning',\n EXPIRED: 'warning',\n EMBARGOED: 'warning',\n RESTRICTED: 'warning',\n UNDER_REVIEW: 'warning',\n // queued / neutral-info\n DRAFT: 'info',\n CONFIGURING: 'info',\n QUEUED: 'info',\n PENDING: 'info',\n WORKSPACE: 'info',\n // failed / removed\n ERROR: 'error',\n FAILED: 'error',\n CANCELLED: 'error',\n RETRACTED: 'error',\n REVOKED: 'error',\n DISABLED: 'error',\n // archived / inert\n ARCHIVED: 'neutral',\n};\n\n/** Turn an ENUM_VALUE into a human label, e.g. GROUND_SENSOR -> \"Ground sensor\". */\nexport function formatEnumLabel(value: string): string {\n const lower = value.replace(/_/g, ' ').toLowerCase();\n return lower.charAt(0).toUpperCase() + lower.slice(1);\n}\n\n/** Known Cos* enum values → translation keys under `cosmicintersection.status`. */\nconst STATUS_LABEL_KEYS: Record<string, string> = {\n DRAFT: 'cosmicintersection.status.draft',\n ACTIVE: 'cosmicintersection.status.active',\n ARCHIVED: 'cosmicintersection.status.archived',\n ERROR: 'cosmicintersection.status.error',\n PENDING: 'cosmicintersection.status.pending',\n RUNNING: 'cosmicintersection.status.running',\n SUCCEEDED: 'cosmicintersection.status.succeeded',\n // COMPLETED (analyses) and PUBLISHED (releases) share the success tone with\n // SUCCEEDED but must keep their own wording: a published release labelled\n // \"Succeeded\" contradicts the \"Published\" status filter on the same page.\n COMPLETED: 'cosmicintersection.status.completed',\n PUBLISHED: 'cosmicintersection.status.published',\n FAILED: 'cosmicintersection.status.failed',\n CANCELLED: 'cosmicintersection.status.cancelled',\n PAUSED: 'cosmicintersection.status.paused',\n DISABLED: 'cosmicintersection.status.disabled',\n ENABLED: 'cosmicintersection.status.enabled',\n PUBLIC: 'cosmicintersection.status.public',\n PRIVATE: 'cosmicintersection.status.private',\n RESTRICTED: 'cosmicintersection.status.restricted',\n};\n\nexport interface StatusBadgeProps {\n status: string;\n /** Override the derived tone (e.g. to force a colour for a domain-specific case). */\n tone?: StatusTone;\n /** Override the rendered label; defaults to a title-cased enum value. */\n label?: string;\n className?: string;\n}\n\nexport function StatusBadge({ status, tone, label, className }: StatusBadgeProps) {\n const tr = useTr();\n const resolvedTone: StatusTone = tone ?? STATUS_TONE[status] ?? 'neutral';\n const fallbackLabel = formatEnumLabel(status);\n const translatedLabel =\n label ??\n (STATUS_LABEL_KEYS[status] ? tr(STATUS_LABEL_KEYS[status], fallbackLabel) : fallbackLabel);\n return (\n <span\n className={`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-medium ${TONE_CLASS[resolvedTone]} ${className ?? ''}`}\n >\n {translatedLabel}\n </span>\n );\n}\n\nexport default StatusBadge;\n"],"mappings":";;;AAcA,IAAM,IAAyC;CAC7C,SAAS;CACT,MAAM;CACN,SAAS;CACT,OAAO;CACP,SAAS;AACX,GAIM,IAA0C;CAE9C,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;CACX,QAAQ;CACR,QAAQ;CAER,WAAW;CACX,SAAS;CACT,SAAS;CACT,UAAU;CACV,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,WAAW;CACX,YAAY;CACZ,cAAc;CAEd,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;CACT,WAAW;CAEX,OAAO;CACP,QAAQ;CACR,WAAW;CACX,WAAW;CACX,SAAS;CACT,UAAU;CAEV,UAAU;AACZ;AAGA,SAAgB,EAAgB,GAAuB;CACrD,IAAM,IAAQ,EAAM,QAAQ,MAAM,GAAG,CAAC,CAAC,YAAY;CACnD,OAAO,EAAM,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,EAAM,MAAM,CAAC;AACtD;AAGA,IAAM,IAA4C;CAChD,OAAO;CACP,QAAQ;CACR,UAAU;CACV,OAAO;CACP,SAAS;CACT,SAAS;CACT,WAAW;CAIX,WAAW;CACX,WAAW;CACX,QAAQ;CACR,WAAW;CACX,QAAQ;CACR,UAAU;CACV,SAAS;CACT,QAAQ;CACR,SAAS;CACT,YAAY;AACd;AAWA,SAAgB,EAAY,EAAE,WAAQ,SAAM,UAAO,gBAA+B;CAChF,IAAM,IAAK,EAAM,GACX,IAA2B,KAAQ,EAAY,MAAW,WAC1D,IAAgB,EAAgB,CAAM,GACtC,IACJ,MACC,EAAkB,KAAU,EAAG,EAAkB,IAAS,CAAa,IAAI;CAC9E,OACE,kBAAC,QAAD;EACE,WAAW,sFAAsF,EAAW,GAAc,GAAG,KAAa;YAEzI;CACG,CAAA;AAEV"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CosRunStatus, CosStepKind } from '../api/cosmicApi';
|
|
2
|
-
|
|
3
2
|
export interface StepDAGStep {
|
|
4
3
|
/** Optional human-authored step name; shown under the kind label when it differs. */
|
|
5
4
|
name?: string | null;
|
|
@@ -15,6 +14,6 @@ export interface StepDAGProps {
|
|
|
15
14
|
* Horizontal (md+) / vertical (mobile) step-flow diagram. Presentational only —
|
|
16
15
|
* callers decide where the step list comes from (pipeline definition or a run).
|
|
17
16
|
*/
|
|
18
|
-
export declare function StepDAG({ steps, className }: StepDAGProps): import(
|
|
17
|
+
export declare function StepDAG({ steps, className }: StepDAGProps): import('react').JSX.Element | null;
|
|
19
18
|
export default StepDAG;
|
|
20
19
|
//# sourceMappingURL=StepDAG.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StepDAG.js","names":[],"sources":["../../../src/cosmicintersection/components/StepDAG.tsx"],"sourcesContent":["/**\n * StepDAG — a lightweight, dependency-free step-flow visualization.\n *\n * Renders an ordered list of pipeline steps as connected rounded nodes: each\n * node shows a per-kind icon + label (and an optional custom step name), and an\n * optional run status tint. Nodes are joined by custom inline-SVG arrow\n * connectors — horizontal on md+ screens, vertical (stacked) on small screens\n * so it never forces a horizontal-scroll.\n *\n * Colour comes only from the semantic token families (bg-bg-*, text-text-*,\n * border-border-*, status-*) — never a raw palette colour — matching mockups\n * 11 & 14.\n */\nimport { Fragment } from 'react';\nimport type { LucideIcon } from 'lucide-react';\nimport {\n Bell,\n Boxes,\n Calculator,\n Database,\n Gauge,\n Globe2,\n Grid3x3,\n Shuffle,\n SlidersHorizontal,\n Upload,\n} from 'lucide-react';\n\nimport type { CosRunStatus, CosStepKind } from '../api/cosmicApi';\nimport { formatEnumLabel } from './StatusBadge';\n\nexport interface StepDAGStep {\n /** Optional human-authored step name; shown under the kind label when it differs. */\n name?: string | null;\n kind: CosStepKind;\n /** Optional run status — tints the node when present. */\n status?: CosRunStatus | null;\n}\n\nexport interface StepDAGProps {\n steps: StepDAGStep[];\n className?: string;\n}\n\nconst KIND_META: Record<CosStepKind, { icon: LucideIcon }> = {\n INGEST: { icon: Database },\n CALIBRATE: { icon: SlidersHorizontal },\n TRANSFORM: { icon: Shuffle },\n ANALYZE: { icon: Gauge },\n EXPORT: { icon: Upload },\n NOTIFY: { icon: Bell },\n // Geospatial kinds (BOFF-4355) — a step can already carry these, so they get\n // a real icon rather than falling through to the generic one.\n RASTER_CALC: { icon: Calculator },\n REPROJECT: { icon: Globe2 },\n TILE: { icon: Grid3x3 },\n ZONAL_STATS: { icon: Boxes },\n};\n\n/** Guards against a kind the subgraph adds before this map catches up. */\nconst FALLBACK_KIND_META: { icon: LucideIcon } = { icon: Boxes };\n\ninterface Accent {\n /** Node border. */\n border: string;\n /** Icon chip background + text. */\n icon: string;\n /** Optional focus ring (used to flag an in-flight node). */\n ring: string;\n}\n\nconst DEFAULT_ACCENT: Accent = {\n border: 'border-border-default',\n icon: 'bg-bg-sunken text-text-secondary',\n ring: '',\n};\n\nconst STATUS_ACCENT: Partial<Record<CosRunStatus, Accent>> = {\n SUCCEEDED: {\n border: 'border-status-success-border',\n icon: 'bg-status-success-bg-subtle text-status-success-text',\n ring: '',\n },\n RUNNING: {\n border: 'border-status-warning-border',\n icon: 'bg-status-warning-bg-subtle text-status-warning-text',\n ring: 'ring-2 ring-status-warning-border',\n },\n FAILED: {\n border: 'border-status-error-border',\n icon: 'bg-status-error-bg-subtle text-status-error-text',\n ring: '',\n },\n QUEUED: {\n border: 'border-status-info-border',\n icon: 'bg-status-info-bg-subtle text-status-info-text',\n ring: '',\n },\n CANCELLED: DEFAULT_ACCENT,\n};\n\n/** Custom inline-SVG connector: a line + arrowhead. Points right on md+, down below. */\nfunction StepConnector() {\n return (\n <span\n aria-hidden=\"true\"\n className=\"flex shrink-0 items-center justify-center text-border-strong\"\n >\n <svg\n viewBox=\"0 0 40 12\"\n className=\"h-4 w-6 rotate-90 md:h-3 md:w-9 md:rotate-0\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.75}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"2\" y1=\"6\" x2=\"33\" y2=\"6\" />\n <path d=\"M28 2 L34 6 L28 10\" />\n </svg>\n </span>\n );\n}\n\nfunction StepNode({ step, index }: { step: StepDAGStep; index: number }) {\n const meta = KIND_META[step.kind] ?? FALLBACK_KIND_META;\n const Icon = meta.icon;\n const accent = (step.status && STATUS_ACCENT[step.status]) || DEFAULT_ACCENT;\n const label = formatEnumLabel(step.kind);\n const showName = Boolean(\n step.name && step.name.trim() && step.name.trim().toLowerCase() !== label.toLowerCase()\n );\n\n return (\n <div\n role=\"listitem\"\n className={`flex w-full items-center gap-3 rounded-card border bg-bg-elevated px-3.5 py-3 md:w-auto md:min-w-[8.5rem] ${accent.border} ${accent.ring}`}\n >\n <span\n className={`flex size-9 shrink-0 items-center justify-center rounded-lg ${accent.icon}`}\n >\n <Icon className=\"size-4\" aria-hidden=\"true\" />\n </span>\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"flex items-baseline gap-1.5\">\n <span className=\"text-[0.65rem] font-semibold tabular-nums text-text-secondary\">\n {index + 1}\n </span>\n <span className=\"truncate text-sm font-medium text-text-primary\">{label}</span>\n </span>\n {showName ? (\n <span className=\"truncate text-xs text-text-secondary\">{step.name}</span>\n ) : null}\n </span>\n </div>\n );\n}\n\n/**\n * Horizontal (md+) / vertical (mobile) step-flow diagram. Presentational only —\n * callers decide where the step list comes from (pipeline definition or a run).\n */\nexport function StepDAG({ steps, className }: StepDAGProps) {\n if (steps.length === 0) {\n return null;\n }\n return (\n <div\n role=\"list\"\n aria-label=\"Pipeline step flow\"\n className={`flex flex-col items-stretch gap-2 md:flex-row md:flex-wrap md:items-center ${className ?? ''}`}\n >\n {steps.map((step, index) => (\n <Fragment key={`${step.kind}-${index}`}>\n <StepNode step={step} index={index} />\n {index < steps.length - 1 ? <StepConnector /> : null}\n </Fragment>\n ))}\n </div>\n );\n}\n\nexport default StepDAG;\n"],"mappings":";;;;;AA4CA,IAAM,IAAuD;CAC3D,QAAQ,EAAE,MAAM,EAAS;CACzB,WAAW,EAAE,MAAM,EAAkB;CACrC,WAAW,EAAE,MAAM,EAAQ;CAC3B,SAAS,EAAE,MAAM,EAAM;CACvB,QAAQ,EAAE,MAAM,EAAO;CACvB,QAAQ,EAAE,MAAM,EAAK;CAGrB,aAAa,EAAE,MAAM,EAAW;CAChC,WAAW,EAAE,MAAM,EAAO;CAC1B,MAAM,EAAE,MAAM,EAAQ;CACtB,aAAa,EAAE,MAAM,EAAM;AAC7B,GAGM,IAA2C,EAAE,MAAM,EAAM,GAWzD,IAAyB;CAC7B,QAAQ;CACR,MAAM;CACN,MAAM;AACR,GAEM,IAAuD;CAC3D,WAAW;EACT,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,SAAS;EACP,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,QAAQ;EACN,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,QAAQ;EACN,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,WAAW;AACb;AAGA,SAAS,IAAgB;CACvB,OACE,kBAAC,QAAD;EACE,eAAY;EACZ,WAAU;YAEV,kBAAC,OAAD;GACE,SAAQ;GACR,WAAU;GACV,MAAK;GACL,QAAO;GACP,aAAa;GACb,eAAc;GACd,gBAAe;aAPjB,CASE,kBAAC,QAAD;IAAM,IAAG;IAAI,IAAG;IAAI,IAAG;IAAK,IAAG;GAAK,CAAA,GACpC,kBAAC,QAAD,EAAM,GAAE,qBAAsB,CAAA,CAC3B;;CACD,CAAA;AAEV;AAEA,SAAS,EAAS,EAAE,SAAM,YAA+C;CAEvE,IAAM,KADO,EAAU,EAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"StepDAG.js","names":[],"sources":["../../../src/cosmicintersection/components/StepDAG.tsx"],"sourcesContent":["/**\n * StepDAG — a lightweight, dependency-free step-flow visualization.\n *\n * Renders an ordered list of pipeline steps as connected rounded nodes: each\n * node shows a per-kind icon + label (and an optional custom step name), and an\n * optional run status tint. Nodes are joined by custom inline-SVG arrow\n * connectors — horizontal on md+ screens, vertical (stacked) on small screens\n * so it never forces a horizontal-scroll.\n *\n * Colour comes only from the semantic token families (bg-bg-*, text-text-*,\n * border-border-*, status-*) — never a raw palette colour — matching mockups\n * 11 & 14.\n */\nimport { Fragment } from 'react';\nimport type { LucideIcon } from 'lucide-react';\nimport {\n Bell,\n Boxes,\n Calculator,\n Database,\n Gauge,\n Globe2,\n Grid3x3,\n Shuffle,\n SlidersHorizontal,\n Upload,\n} from 'lucide-react';\n\nimport type { CosRunStatus, CosStepKind } from '../api/cosmicApi';\nimport { formatEnumLabel } from './StatusBadge';\n\nexport interface StepDAGStep {\n /** Optional human-authored step name; shown under the kind label when it differs. */\n name?: string | null;\n kind: CosStepKind;\n /** Optional run status — tints the node when present. */\n status?: CosRunStatus | null;\n}\n\nexport interface StepDAGProps {\n steps: StepDAGStep[];\n className?: string;\n}\n\nconst KIND_META: Record<CosStepKind, { icon: LucideIcon }> = {\n INGEST: { icon: Database },\n CALIBRATE: { icon: SlidersHorizontal },\n TRANSFORM: { icon: Shuffle },\n ANALYZE: { icon: Gauge },\n EXPORT: { icon: Upload },\n NOTIFY: { icon: Bell },\n // Geospatial kinds (BOFF-4355) — a step can already carry these, so they get\n // a real icon rather than falling through to the generic one.\n RASTER_CALC: { icon: Calculator },\n REPROJECT: { icon: Globe2 },\n TILE: { icon: Grid3x3 },\n ZONAL_STATS: { icon: Boxes },\n};\n\n/** Guards against a kind the subgraph adds before this map catches up. */\nconst FALLBACK_KIND_META: { icon: LucideIcon } = { icon: Boxes };\n\ninterface Accent {\n /** Node border. */\n border: string;\n /** Icon chip background + text. */\n icon: string;\n /** Optional focus ring (used to flag an in-flight node). */\n ring: string;\n}\n\nconst DEFAULT_ACCENT: Accent = {\n border: 'border-border-default',\n icon: 'bg-bg-sunken text-text-secondary',\n ring: '',\n};\n\nconst STATUS_ACCENT: Partial<Record<CosRunStatus, Accent>> = {\n SUCCEEDED: {\n border: 'border-status-success-border',\n icon: 'bg-status-success-bg-subtle text-status-success-text',\n ring: '',\n },\n RUNNING: {\n border: 'border-status-warning-border',\n icon: 'bg-status-warning-bg-subtle text-status-warning-text',\n ring: 'ring-2 ring-status-warning-border',\n },\n FAILED: {\n border: 'border-status-error-border',\n icon: 'bg-status-error-bg-subtle text-status-error-text',\n ring: '',\n },\n QUEUED: {\n border: 'border-status-info-border',\n icon: 'bg-status-info-bg-subtle text-status-info-text',\n ring: '',\n },\n CANCELLED: DEFAULT_ACCENT,\n};\n\n/** Custom inline-SVG connector: a line + arrowhead. Points right on md+, down below. */\nfunction StepConnector() {\n return (\n <span\n aria-hidden=\"true\"\n className=\"flex shrink-0 items-center justify-center text-border-strong\"\n >\n <svg\n viewBox=\"0 0 40 12\"\n className=\"h-4 w-6 rotate-90 md:h-3 md:w-9 md:rotate-0\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth={1.75}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <line x1=\"2\" y1=\"6\" x2=\"33\" y2=\"6\" />\n <path d=\"M28 2 L34 6 L28 10\" />\n </svg>\n </span>\n );\n}\n\nfunction StepNode({ step, index }: { step: StepDAGStep; index: number }) {\n const meta = KIND_META[step.kind] ?? FALLBACK_KIND_META;\n const Icon = meta.icon;\n const accent = (step.status && STATUS_ACCENT[step.status]) || DEFAULT_ACCENT;\n const label = formatEnumLabel(step.kind);\n const showName = Boolean(\n step.name && step.name.trim() && step.name.trim().toLowerCase() !== label.toLowerCase()\n );\n\n return (\n <div\n role=\"listitem\"\n className={`flex w-full items-center gap-3 rounded-card border bg-bg-elevated px-3.5 py-3 md:w-auto md:min-w-[8.5rem] ${accent.border} ${accent.ring}`}\n >\n <span\n className={`flex size-9 shrink-0 items-center justify-center rounded-lg ${accent.icon}`}\n >\n <Icon className=\"size-4\" aria-hidden=\"true\" />\n </span>\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"flex items-baseline gap-1.5\">\n <span className=\"text-[0.65rem] font-semibold tabular-nums text-text-secondary\">\n {index + 1}\n </span>\n <span className=\"truncate text-sm font-medium text-text-primary\">{label}</span>\n </span>\n {showName ? (\n <span className=\"truncate text-xs text-text-secondary\">{step.name}</span>\n ) : null}\n </span>\n </div>\n );\n}\n\n/**\n * Horizontal (md+) / vertical (mobile) step-flow diagram. Presentational only —\n * callers decide where the step list comes from (pipeline definition or a run).\n */\nexport function StepDAG({ steps, className }: StepDAGProps) {\n if (steps.length === 0) {\n return null;\n }\n return (\n <div\n role=\"list\"\n aria-label=\"Pipeline step flow\"\n className={`flex flex-col items-stretch gap-2 md:flex-row md:flex-wrap md:items-center ${className ?? ''}`}\n >\n {steps.map((step, index) => (\n <Fragment key={`${step.kind}-${index}`}>\n <StepNode step={step} index={index} />\n {index < steps.length - 1 ? <StepConnector /> : null}\n </Fragment>\n ))}\n </div>\n );\n}\n\nexport default StepDAG;\n"],"mappings":";;;;;AA4CA,IAAM,IAAuD;CAC3D,QAAQ,EAAE,MAAM,EAAS;CACzB,WAAW,EAAE,MAAM,EAAkB;CACrC,WAAW,EAAE,MAAM,EAAQ;CAC3B,SAAS,EAAE,MAAM,EAAM;CACvB,QAAQ,EAAE,MAAM,EAAO;CACvB,QAAQ,EAAE,MAAM,EAAK;CAGrB,aAAa,EAAE,MAAM,EAAW;CAChC,WAAW,EAAE,MAAM,EAAO;CAC1B,MAAM,EAAE,MAAM,EAAQ;CACtB,aAAa,EAAE,MAAM,EAAM;AAC7B,GAGM,IAA2C,EAAE,MAAM,EAAM,GAWzD,IAAyB;CAC7B,QAAQ;CACR,MAAM;CACN,MAAM;AACR,GAEM,IAAuD;CAC3D,WAAW;EACT,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,SAAS;EACP,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,QAAQ;EACN,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,QAAQ;EACN,QAAQ;EACR,MAAM;EACN,MAAM;CACR;CACA,WAAW;AACb;AAGA,SAAS,IAAgB;CACvB,OACE,kBAAC,QAAD;EACE,eAAY;EACZ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AAA,GACpC,IAAQ,EAAM,SAAS,IAAI,kBAAC,GAAD,CAAgB,CAAA,IAAI,IACxC,EAAA,GAHK,GAAG,EAAK,KAAK,GAAG,GAGrB,CACX;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface WorkspaceTagsPickerProps {
|
|
2
|
+
/** Selected tag labels (mirrors the entity's inline `tags: [String!]` array). */
|
|
3
|
+
value: string[];
|
|
4
|
+
/** Called with the next label array whenever a tag is added or removed. */
|
|
5
|
+
onChange: (tags: string[]) => void;
|
|
6
|
+
label?: string;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Max suggestions shown under the input. */
|
|
11
|
+
suggestionLimit?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Workspace-aware tag picker for CosmicIntersection entity forms.
|
|
15
|
+
*
|
|
16
|
+
* Suggests existing tags from the workspace taxonomy (wspace-tags-svc, via the
|
|
17
|
+
* `availableCosTags` field of this product's subgraph) and lets the user add a
|
|
18
|
+
* brand-new tag when nothing matches. New labels are created in the taxonomy
|
|
19
|
+
* when the form saves (`useEntityTagSync`), so cancelling a form never leaves
|
|
20
|
+
* orphan tags behind. When the taxonomy cannot be loaded the picker still
|
|
21
|
+
* works as a plain chips input.
|
|
22
|
+
*
|
|
23
|
+
* Self-contained by design: MFEs never import each other, so this lives here
|
|
24
|
+
* rather than in microfe-tags (which owns the full `/tags` management UI).
|
|
25
|
+
*/
|
|
26
|
+
export declare function WorkspaceTagsPicker({ value, onChange, label, placeholder, disabled, className, suggestionLimit, }: WorkspaceTagsPickerProps): import('react').JSX.Element;
|
|
27
|
+
//# sourceMappingURL=WorkspaceTagsPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceTagsPicker.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/components/WorkspaceTagsPicker.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,wBAAwB;IACvC,iFAAiF;IACjF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,2EAA2E;IAC3E,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,KAAK,EACL,QAAQ,EACR,KAAc,EACd,WAAsD,EACtD,QAAgB,EAChB,SAAS,EACT,eAAmB,GACpB,EAAE,wBAAwB,+BAqJ1B"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { cleanTagLabel as e, findTagByLabel as t, normalizeTagLabel as n, suggestWorkspaceTags as r, useWorkspaceTags as i } from "../api/tagsApi.js";
|
|
2
|
+
import { useId as a, useMemo as o, useState as s } from "react";
|
|
3
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
4
|
+
import { Plus as u, Tag as d, X as f } from "lucide-react";
|
|
5
|
+
import { Badge as p, Button as m, Input as h } from "@burdenoff/fe-libs/ui";
|
|
6
|
+
//#region src/cosmicintersection/components/WorkspaceTagsPicker.tsx
|
|
7
|
+
function g({ value: g, onChange: _, label: v = "Tags", placeholder: y = "Search workspace tags or add a new one", disabled: b = !1, className: x, suggestionLimit: S = 8 }) {
|
|
8
|
+
let [C, w] = s(""), T = a(), { data: E, loading: D, error: O } = i(b), k = o(() => E?.availableCosTags ?? [], [E]), A = o(() => r(k, g, C, S), [
|
|
9
|
+
k,
|
|
10
|
+
g,
|
|
11
|
+
C,
|
|
12
|
+
S
|
|
13
|
+
]), j = e(C), M = n(j), N = g.some((e) => n(e) === M), P = t(k, j), F = j !== "" && !N && !P, I = (t) => {
|
|
14
|
+
let r = e(t);
|
|
15
|
+
r && (g.some((e) => n(e) === n(r)) || _([...g, r]), w(""));
|
|
16
|
+
}, L = () => {
|
|
17
|
+
j && I(P?.label ?? j);
|
|
18
|
+
}, R = (e) => {
|
|
19
|
+
let t = n(e);
|
|
20
|
+
_(g.filter((e) => n(e) !== t));
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ l("div", {
|
|
23
|
+
className: `space-y-2 ${x ?? ""}`,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ l("div", {
|
|
26
|
+
className: "flex items-center gap-2 text-sm font-medium text-text-primary",
|
|
27
|
+
children: [/* @__PURE__ */ c(d, {
|
|
28
|
+
className: "size-4 text-text-secondary",
|
|
29
|
+
"aria-hidden": "true"
|
|
30
|
+
}), /* @__PURE__ */ c("span", { children: v })]
|
|
31
|
+
}),
|
|
32
|
+
/* @__PURE__ */ c("div", {
|
|
33
|
+
className: "flex flex-wrap gap-2",
|
|
34
|
+
role: "list",
|
|
35
|
+
"aria-label": v,
|
|
36
|
+
children: g.length === 0 ? /* @__PURE__ */ c("span", {
|
|
37
|
+
className: "text-sm text-text-secondary",
|
|
38
|
+
children: "No tags yet."
|
|
39
|
+
}) : g.map((e) => /* @__PURE__ */ l(p, {
|
|
40
|
+
variant: "secondary",
|
|
41
|
+
className: "gap-1.5",
|
|
42
|
+
role: "listitem",
|
|
43
|
+
children: [/* @__PURE__ */ c("span", {
|
|
44
|
+
className: "min-w-0 truncate",
|
|
45
|
+
children: e
|
|
46
|
+
}), /* @__PURE__ */ c("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
onClick: () => R(e),
|
|
49
|
+
disabled: b,
|
|
50
|
+
"aria-label": `Remove ${e}`,
|
|
51
|
+
className: "rounded-full text-text-secondary transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-focus disabled:opacity-50",
|
|
52
|
+
children: /* @__PURE__ */ c(f, {
|
|
53
|
+
className: "size-3",
|
|
54
|
+
"aria-hidden": "true"
|
|
55
|
+
})
|
|
56
|
+
})]
|
|
57
|
+
}, e))
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ l("div", {
|
|
60
|
+
className: "flex items-center gap-2",
|
|
61
|
+
children: [/* @__PURE__ */ c(h, {
|
|
62
|
+
value: C,
|
|
63
|
+
onChange: (e) => w(e.target.value),
|
|
64
|
+
placeholder: y,
|
|
65
|
+
"aria-label": `${v} input`,
|
|
66
|
+
"aria-controls": T,
|
|
67
|
+
maxLength: 64,
|
|
68
|
+
disabled: b,
|
|
69
|
+
className: "w-full max-w-xs",
|
|
70
|
+
onKeyDown: (e) => {
|
|
71
|
+
e.key === "Enter" && (e.preventDefault(), L());
|
|
72
|
+
}
|
|
73
|
+
}), /* @__PURE__ */ l(m, {
|
|
74
|
+
type: "button",
|
|
75
|
+
variant: "outline",
|
|
76
|
+
size: "sm",
|
|
77
|
+
onClick: L,
|
|
78
|
+
disabled: b || !j,
|
|
79
|
+
children: [/* @__PURE__ */ c(u, { className: "size-4" }), "Add"]
|
|
80
|
+
})]
|
|
81
|
+
}),
|
|
82
|
+
b ? null : /* @__PURE__ */ l("div", {
|
|
83
|
+
id: T,
|
|
84
|
+
className: "flex flex-wrap items-center gap-2",
|
|
85
|
+
"aria-label": `${v} suggestions`,
|
|
86
|
+
role: "group",
|
|
87
|
+
children: [
|
|
88
|
+
A.length > 0 ? /* @__PURE__ */ c("span", {
|
|
89
|
+
className: "text-xs text-text-secondary",
|
|
90
|
+
children: j ? "Matching tags:" : "Workspace tags:"
|
|
91
|
+
}) : null,
|
|
92
|
+
A.map((e) => /* @__PURE__ */ l(m, {
|
|
93
|
+
type: "button",
|
|
94
|
+
variant: "ghost",
|
|
95
|
+
size: "sm",
|
|
96
|
+
className: "h-7 px-2 text-xs",
|
|
97
|
+
onClick: () => I(e.label),
|
|
98
|
+
"aria-label": `Add workspace tag ${e.label}`,
|
|
99
|
+
children: [/* @__PURE__ */ c(d, {
|
|
100
|
+
className: "size-3",
|
|
101
|
+
"aria-hidden": "true"
|
|
102
|
+
}), e.label]
|
|
103
|
+
}, e.id)),
|
|
104
|
+
F ? /* @__PURE__ */ l(m, {
|
|
105
|
+
type: "button",
|
|
106
|
+
variant: "ghost",
|
|
107
|
+
size: "sm",
|
|
108
|
+
className: "h-7 px-2 text-xs",
|
|
109
|
+
onClick: () => I(j),
|
|
110
|
+
"aria-label": `Create tag ${j}`,
|
|
111
|
+
children: [
|
|
112
|
+
/* @__PURE__ */ c(u, {
|
|
113
|
+
className: "size-3",
|
|
114
|
+
"aria-hidden": "true"
|
|
115
|
+
}),
|
|
116
|
+
"Create “",
|
|
117
|
+
j,
|
|
118
|
+
"”"
|
|
119
|
+
]
|
|
120
|
+
}) : null,
|
|
121
|
+
D && k.length === 0 ? /* @__PURE__ */ c("span", {
|
|
122
|
+
className: "text-xs text-text-secondary",
|
|
123
|
+
children: "Loading workspace tags…"
|
|
124
|
+
}) : null,
|
|
125
|
+
O && k.length === 0 ? /* @__PURE__ */ c("span", {
|
|
126
|
+
className: "text-xs text-text-secondary",
|
|
127
|
+
children: "Workspace tags are unavailable right now; new tags are still saved."
|
|
128
|
+
}) : null,
|
|
129
|
+
!D && !O && k.length === 0 && !F ? /* @__PURE__ */ c("span", {
|
|
130
|
+
className: "text-xs text-text-secondary",
|
|
131
|
+
children: "No workspace tags yet. Type a name to create the first one."
|
|
132
|
+
}) : null
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { g as WorkspaceTagsPicker };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=WorkspaceTagsPicker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkspaceTagsPicker.js","names":[],"sources":["../../../src/cosmicintersection/components/WorkspaceTagsPicker.tsx"],"sourcesContent":["import { useId, useMemo, useState } from 'react';\nimport { Plus, Tag as TagIcon, X } from 'lucide-react';\nimport { Badge, Button, Input } from '@burdenoff/fe-libs/ui';\n\nimport {\n MAX_TAG_LABEL_LENGTH,\n cleanTagLabel,\n findTagByLabel,\n normalizeTagLabel,\n suggestWorkspaceTags,\n useWorkspaceTags,\n} from '../api/tagsApi';\n\nexport interface WorkspaceTagsPickerProps {\n /** Selected tag labels (mirrors the entity's inline `tags: [String!]` array). */\n value: string[];\n /** Called with the next label array whenever a tag is added or removed. */\n onChange: (tags: string[]) => void;\n label?: string;\n placeholder?: string;\n disabled?: boolean;\n className?: string;\n /** Max suggestions shown under the input. */\n suggestionLimit?: number;\n}\n\n/**\n * Workspace-aware tag picker for CosmicIntersection entity forms.\n *\n * Suggests existing tags from the workspace taxonomy (wspace-tags-svc, via the\n * `availableCosTags` field of this product's subgraph) and lets the user add a\n * brand-new tag when nothing matches. New labels are created in the taxonomy\n * when the form saves (`useEntityTagSync`), so cancelling a form never leaves\n * orphan tags behind. When the taxonomy cannot be loaded the picker still\n * works as a plain chips input.\n *\n * Self-contained by design: MFEs never import each other, so this lives here\n * rather than in microfe-tags (which owns the full `/tags` management UI).\n */\nexport function WorkspaceTagsPicker({\n value,\n onChange,\n label = 'Tags',\n placeholder = 'Search workspace tags or add a new one',\n disabled = false,\n className,\n suggestionLimit = 8,\n}: WorkspaceTagsPickerProps) {\n const [draft, setDraft] = useState('');\n const listId = useId();\n const { data, loading, error } = useWorkspaceTags(disabled);\n\n const workspaceTags = useMemo(() => data?.availableCosTags ?? [], [data]);\n const suggestions = useMemo(\n () => suggestWorkspaceTags(workspaceTags, value, draft, suggestionLimit),\n [workspaceTags, value, draft, suggestionLimit]\n );\n const trimmed = cleanTagLabel(draft);\n const normalized = normalizeTagLabel(trimmed);\n const alreadySelected = value.some((tag) => normalizeTagLabel(tag) === normalized);\n const existing = findTagByLabel(workspaceTags, trimmed);\n const canCreate = trimmed !== '' && !alreadySelected && !existing;\n\n const addTag = (next: string) => {\n const clean = cleanTagLabel(next);\n if (!clean) return;\n if (!value.some((tag) => normalizeTagLabel(tag) === normalizeTagLabel(clean))) {\n onChange([...value, clean]);\n }\n setDraft('');\n };\n\n /** Enter picks the matching workspace tag (keeping its canonical label), else adds the typed text. */\n const commitDraft = () => {\n if (!trimmed) return;\n addTag(existing?.label ?? trimmed);\n };\n\n const removeTag = (tag: string) => {\n const key = normalizeTagLabel(tag);\n onChange(value.filter((existingTag) => normalizeTagLabel(existingTag) !== key));\n };\n\n return (\n <div className={`space-y-2 ${className ?? ''}`}>\n <div className=\"flex items-center gap-2 text-sm font-medium text-text-primary\">\n <TagIcon className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span>{label}</span>\n </div>\n\n <div className=\"flex flex-wrap gap-2\" role=\"list\" aria-label={label}>\n {value.length === 0 ? (\n <span className=\"text-sm text-text-secondary\">No tags yet.</span>\n ) : (\n value.map((tag) => (\n <Badge key={tag} variant=\"secondary\" className=\"gap-1.5\" role=\"listitem\">\n <span className=\"min-w-0 truncate\">{tag}</span>\n <button\n type=\"button\"\n onClick={() => removeTag(tag)}\n disabled={disabled}\n aria-label={`Remove ${tag}`}\n className=\"rounded-full text-text-secondary transition-colors hover:text-text-primary focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-border-focus disabled:opacity-50\"\n >\n <X className=\"size-3\" aria-hidden=\"true\" />\n </button>\n </Badge>\n ))\n )}\n </div>\n\n <div className=\"flex items-center gap-2\">\n <Input\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={placeholder}\n aria-label={`${label} input`}\n aria-controls={listId}\n maxLength={MAX_TAG_LABEL_LENGTH}\n disabled={disabled}\n className=\"w-full max-w-xs\"\n onKeyDown={(event) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n commitDraft();\n }\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={commitDraft}\n disabled={disabled || !trimmed}\n >\n <Plus className=\"size-4\" />\n Add\n </Button>\n </div>\n\n {disabled ? null : (\n <div\n id={listId}\n className=\"flex flex-wrap items-center gap-2\"\n aria-label={`${label} suggestions`}\n role=\"group\"\n >\n {suggestions.length > 0 ? (\n <span className=\"text-xs text-text-secondary\">\n {trimmed ? 'Matching tags:' : 'Workspace tags:'}\n </span>\n ) : null}\n {suggestions.map((tag) => (\n <Button\n key={tag.id}\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-7 px-2 text-xs\"\n onClick={() => addTag(tag.label)}\n aria-label={`Add workspace tag ${tag.label}`}\n >\n <TagIcon className=\"size-3\" aria-hidden=\"true\" />\n {tag.label}\n </Button>\n ))}\n {canCreate ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n className=\"h-7 px-2 text-xs\"\n onClick={() => addTag(trimmed)}\n aria-label={`Create tag ${trimmed}`}\n >\n <Plus className=\"size-3\" aria-hidden=\"true\" />\n Create “{trimmed}”\n </Button>\n ) : null}\n {loading && workspaceTags.length === 0 ? (\n <span className=\"text-xs text-text-secondary\">Loading workspace tags…</span>\n ) : null}\n {error && workspaceTags.length === 0 ? (\n <span className=\"text-xs text-text-secondary\">\n Workspace tags are unavailable right now; new tags are still saved.\n </span>\n ) : null}\n {!loading && !error && workspaceTags.length === 0 && !canCreate ? (\n <span className=\"text-xs text-text-secondary\">\n No workspace tags yet. Type a name to create the first one.\n </span>\n ) : null}\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,EAAoB,EAClC,UACA,aACA,WAAQ,QACR,iBAAc,0CACd,cAAW,IACX,cACA,qBAAkB,KACS;CAC3B,IAAM,CAAC,GAAO,KAAY,EAAS,EAAE,GAC/B,IAAS,EAAM,GACf,EAAE,SAAM,YAAS,aAAU,EAAiB,CAAQ,GAEpD,IAAgB,QAAc,GAAM,oBAAoB,CAAC,GAAG,CAAC,CAAI,CAAC,GAClE,IAAc,QACZ,EAAqB,GAAe,GAAO,GAAO,CAAe,GACvE;EAAC;EAAe;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EAAc,WAAW,KAAK,CAAC,IACpD,kBAAC,QAAD;MAAM,WAAU;gBAA8B;KAExC,CAAA,IACJ;IACD;;EAEJ;;AAET"}
|
|
@@ -8,6 +8,7 @@ export { DiscussionPanel, type DiscussionPanelProps } from './DiscussionPanel';
|
|
|
8
8
|
export { EmptyState, type EmptyStateProps } from './EmptyState';
|
|
9
9
|
export { EntityFormShell, type EntityFormShellProps } from './EntityFormShell';
|
|
10
10
|
export { EntityTagsField, type EntityTagsFieldProps } from './EntityTagsField';
|
|
11
|
+
export { WorkspaceTagsPicker, type WorkspaceTagsPickerProps } from './WorkspaceTagsPicker';
|
|
11
12
|
export { ErrorState, type ErrorStateProps } from './ErrorState';
|
|
12
13
|
export { FileUploadField, GET_FILE_DOWNLOAD_URL, useFileDownloadUrl, type FileUploadFieldProps, } from './FileUploadField';
|
|
13
14
|
export { LoadingState, type LoadingStateProps } from './LoadingState';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cosmicintersection/components/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,eAAe,EACf,qBAAqB,EACr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MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,UAAU,EACV,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACL,WAAW,EACX,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,eAAe,CAAC"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import "./ActionMenu.js";
|
|
2
|
-
import "./EmptyState.js";
|
|
3
|
-
import "./ErrorState.js";
|
|
4
|
-
import "./LoadingState.js";
|
|
5
|
-
import "./ActivityFeedPanel.js";
|
|
6
|
-
import "./SafeLink.js";
|
|
7
|
-
import "./DiscussionPanel.js";
|
|
8
|
-
import "./EntityFormShell.js";
|
|
9
|
-
import "./EntityTagsField.js";
|
|
10
|
-
import "./
|
|
11
|
-
import "./
|
|
12
|
-
import "./
|
|
13
|
-
import "./
|
|
1
|
+
import { ActionMenu as e } from "./ActionMenu.js";
|
|
2
|
+
import { EmptyState as t } from "./EmptyState.js";
|
|
3
|
+
import { ErrorState as n } from "./ErrorState.js";
|
|
4
|
+
import { LoadingState as r } from "./LoadingState.js";
|
|
5
|
+
import { ActivityFeedPanel as i } from "./ActivityFeedPanel.js";
|
|
6
|
+
import { SafeLink as a } from "./SafeLink.js";
|
|
7
|
+
import { DiscussionPanel as o } from "./DiscussionPanel.js";
|
|
8
|
+
import { EntityFormShell as s } from "./EntityFormShell.js";
|
|
9
|
+
import { EntityTagsField as c } from "./EntityTagsField.js";
|
|
10
|
+
import { WorkspaceTagsPicker as l } from "./WorkspaceTagsPicker.js";
|
|
11
|
+
import { FileUploadField as u, useFileDownloadUrl as d } from "./FileUploadField.js";
|
|
12
|
+
import { PageLayout as f } from "./PageLayout.js";
|
|
13
|
+
import { Pagination as p, usePagination as m } from "./Pagination.js";
|
|
14
|
+
import { StatusBadge as h, formatEnumLabel as g } from "./StatusBadge.js";
|
|
15
|
+
export { e as ActionMenu, i as ActivityFeedPanel, o as DiscussionPanel, t as EmptyState, s as EntityFormShell, c as EntityTagsField, n as ErrorState, u as FileUploadField, r as LoadingState, f as PageLayout, p as Pagination, a as SafeLink, h as StatusBadge, l as WorkspaceTagsPicker, g as formatEnumLabel, d as useFileDownloadUrl, m as usePagination };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { CosmicIntersectionRootProps } from '../types';
|
|
3
|
-
|
|
4
3
|
interface CosmicIntersectionContextValue {
|
|
5
4
|
basePath: string;
|
|
6
5
|
navigate: (path: string) => void;
|
|
@@ -14,7 +13,7 @@ interface CosmicIntersectionProviderProps {
|
|
|
14
13
|
children: ReactNode;
|
|
15
14
|
props: CosmicIntersectionRootProps;
|
|
16
15
|
}
|
|
17
|
-
export declare function CosmicIntersectionProvider({ children, props }: CosmicIntersectionProviderProps): import(
|
|
16
|
+
export declare function CosmicIntersectionProvider({ children, props }: CosmicIntersectionProviderProps): import('react').JSX.Element;
|
|
18
17
|
export declare function useCosmicIntersection(): CosmicIntersectionContextValue;
|
|
19
18
|
/**
|
|
20
19
|
* Hook for basePath-aware navigation. Returns a navigate function that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CosmicIntersectionContext.js","names":[],"sources":["../../../src/cosmicintersection/context/CosmicIntersectionContext.tsx"],"sourcesContent":["/**\n * CosmicIntersectionContext\n *\n * Provides basePath-aware navigation and shared props throughout the\n * CosmicIntersection microfrontend. Uses the `navigate` function injected by the\n * host app shell — no react-router hooks are needed here, so the same tree works\n * whether the shell drives routing or the local dev harness does.\n */\n\nimport { createContext, useCallback, useContext, useMemo, type ReactNode } from 'react';\nimport type { CosmicIntersectionRootProps } from '../types';\n\ninterface CosmicIntersectionContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: CosmicIntersectionRootProps['currentUser'];\n workspaceId?: string;\n tenantId?: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst CosmicIntersectionContext = createContext<CosmicIntersectionContextValue | null>(null);\n\ninterface CosmicIntersectionProviderProps {\n children: ReactNode;\n props: CosmicIntersectionRootProps;\n}\n\nexport function CosmicIntersectionProvider({ children, props }: CosmicIntersectionProviderProps) {\n const {\n basePath = '',\n navigate: hostNavigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n } = props;\n\n // Normalize basePath (strip trailing slash) so joins never produce `//`.\n const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n\n // basePath-aware navigation built on the host's navigate function.\n const navigate = useCallback(\n (path: string) => {\n if (!normalizedBasePath || normalizedBasePath === '/') {\n hostNavigate(path);\n return;\n }\n if (path.startsWith(normalizedBasePath)) {\n hostNavigate(path);\n return;\n }\n const fullPath = path.startsWith('/')\n ? `${normalizedBasePath}${path}`\n : `${normalizedBasePath}/${path}`;\n hostNavigate(fullPath);\n },\n [normalizedBasePath, hostNavigate]\n );\n\n const value = useMemo(\n () => ({\n basePath: normalizedBasePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl: apiGatewayUrl || '',\n authToken: authToken || '',\n }),\n [normalizedBasePath, navigate, currentUser, workspaceId, tenantId, apiGatewayUrl, authToken]\n );\n\n return (\n <CosmicIntersectionContext.Provider value={value}>\n {children}\n </CosmicIntersectionContext.Provider>\n );\n}\n\nexport function useCosmicIntersection() {\n const context = useContext(CosmicIntersectionContext);\n if (!context) {\n throw new Error('useCosmicIntersection must be used within a CosmicIntersectionProvider');\n }\n return context;\n}\n\n/**\n * Hook for basePath-aware navigation. Returns a navigate function that\n * automatically prepends the microfrontend basePath. Falls back to a\n * `window.location`-based navigate if used outside the provider.\n */\nexport function useCosmicIntersectionNavigate() {\n const context = useContext(CosmicIntersectionContext);\n\n const fallbackNavigate = useCallback((path: string) => {\n const currentPath = window.location.pathname;\n const mfeMatch = currentPath.match(/^(\\/cosmicintersection)/);\n const basePath = mfeMatch ? mfeMatch[1] : '';\n\n let fullPath = path;\n if (basePath && !path.startsWith(basePath)) {\n fullPath = path.startsWith('/') ? `${basePath}${path}` : `${basePath}/${path}`;\n }\n window.location.href = fullPath;\n }, []);\n\n return context?.navigate ?? fallbackNavigate;\n}\n"],"mappings":";;;AAsBA,IAAM,IAA4B,EAAqD,IAAI;AAO3F,SAAgB,EAA2B,EAAE,aAAU,YAA0C;CAC/F,IAAM,EACJ,cAAW,IACX,UAAU,GACV,gBACA,gBACA,aACA,kBACA,iBACE,GAGE,IAAqB,EAAS,SAAS,GAAG,IAAI,EAAS,MAAM,GAAG,EAAE,IAAI,GAGtE,IAAW,GACd,MAAiB;EAChB,IAAI,CAAC,KAAsB,MAAuB,KAAK;GACrD,EAAa,CAAI;GACjB;EACF;EACA,IAAI,EAAK,WAAW,CAAkB,GAAG;GACvC,EAAa,CAAI;GACjB;EACF;
|
|
1
|
+
{"version":3,"file":"CosmicIntersectionContext.js","names":[],"sources":["../../../src/cosmicintersection/context/CosmicIntersectionContext.tsx"],"sourcesContent":["/**\n * CosmicIntersectionContext\n *\n * Provides basePath-aware navigation and shared props throughout the\n * CosmicIntersection microfrontend. Uses the `navigate` function injected by the\n * host app shell — no react-router hooks are needed here, so the same tree works\n * whether the shell drives routing or the local dev harness does.\n */\n\nimport { createContext, useCallback, useContext, useMemo, type ReactNode } from 'react';\nimport type { CosmicIntersectionRootProps } from '../types';\n\ninterface CosmicIntersectionContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: CosmicIntersectionRootProps['currentUser'];\n workspaceId?: string;\n tenantId?: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst CosmicIntersectionContext = createContext<CosmicIntersectionContextValue | null>(null);\n\ninterface CosmicIntersectionProviderProps {\n children: ReactNode;\n props: CosmicIntersectionRootProps;\n}\n\nexport function CosmicIntersectionProvider({ children, props }: CosmicIntersectionProviderProps) {\n const {\n basePath = '',\n navigate: hostNavigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl,\n authToken,\n } = props;\n\n // Normalize basePath (strip trailing slash) so joins never produce `//`.\n const normalizedBasePath = basePath.endsWith('/') ? basePath.slice(0, -1) : basePath;\n\n // basePath-aware navigation built on the host's navigate function.\n const navigate = useCallback(\n (path: string) => {\n if (!normalizedBasePath || normalizedBasePath === '/') {\n hostNavigate(path);\n return;\n }\n if (path.startsWith(normalizedBasePath)) {\n hostNavigate(path);\n return;\n }\n const fullPath = path.startsWith('/')\n ? `${normalizedBasePath}${path}`\n : `${normalizedBasePath}/${path}`;\n hostNavigate(fullPath);\n },\n [normalizedBasePath, hostNavigate]\n );\n\n const value = useMemo(\n () => ({\n basePath: normalizedBasePath,\n navigate,\n currentUser,\n workspaceId,\n tenantId,\n apiGatewayUrl: apiGatewayUrl || '',\n authToken: authToken || '',\n }),\n [normalizedBasePath, navigate, currentUser, workspaceId, tenantId, apiGatewayUrl, authToken]\n );\n\n return (\n <CosmicIntersectionContext.Provider value={value}>\n {children}\n </CosmicIntersectionContext.Provider>\n );\n}\n\nexport function useCosmicIntersection() {\n const context = useContext(CosmicIntersectionContext);\n if (!context) {\n throw new Error('useCosmicIntersection must be used within a CosmicIntersectionProvider');\n }\n return context;\n}\n\n/**\n * Hook for basePath-aware navigation. Returns a navigate function that\n * automatically prepends the microfrontend basePath. Falls back to a\n * `window.location`-based navigate if used outside the provider.\n */\nexport function useCosmicIntersectionNavigate() {\n const context = useContext(CosmicIntersectionContext);\n\n const fallbackNavigate = useCallback((path: string) => {\n const currentPath = window.location.pathname;\n const mfeMatch = currentPath.match(/^(\\/cosmicintersection)/);\n const basePath = mfeMatch ? mfeMatch[1] : '';\n\n let fullPath = path;\n if (basePath && !path.startsWith(basePath)) {\n fullPath = path.startsWith('/') ? `${basePath}${path}` : `${basePath}/${path}`;\n }\n window.location.href = fullPath;\n }, []);\n\n return context?.navigate ?? fallbackNavigate;\n}\n"],"mappings":";;;AAsBA,IAAM,IAA4B,EAAqD,IAAI;AAO3F,SAAgB,EAA2B,EAAE,aAAU,YAA0C;CAC/F,IAAM,EACJ,cAAW,IACX,UAAU,GACV,gBACA,gBACA,aACA,kBACA,iBACE,GAGE,IAAqB,EAAS,SAAS,GAAG,IAAI,EAAS,MAAM,GAAG,EAAE,IAAI,GAGtE,IAAW,GACd,MAAiB;EAChB,IAAI,CAAC,KAAsB,MAAuB,KAAK;GACrD,EAAa,CAAI;GACjB;EACF;EACA,IAAI,EAAK,WAAW,CAAkB,GAAG;GACvC,EAAa,CAAI;GACjB;EACF;EACA,IAAM,IAAW,EAAK,WAAW,GAAG,IAChC,GAAG,IAAqB,MACxB,GAAG,EAAmB,GAAG;EAC7B,EAAa,CAAQ;CACvB,GACA,CAAC,GAAoB,CAAY,CACnC,GAEM,IAAQ,SACL;EACL,UAAU;EACV;EACA;EACA;EACA;EACA,eAAe,KAAiB;EAChC,WAAW,KAAa;CAC1B,IACA;EAAC;EAAoB;EAAU;EAAa;EAAa;EAAU;EAAe;CAAS,CAC7F;CAEA,OACE,kBAAC,EAA0B,UAA3B;EAA2C;EACxC;CACiC,CAAA;AAExC;AAEA,SAAgB,IAAwB;CACtC,IAAM,IAAU,EAAW,CAAyB;CACpD,IAAI,CAAC,GACH,MAAU,MAAM,wEAAwE;CAE1F,OAAO;AACT"}
|