@pablo2410/shared-ui 0.19.1 → 0.21.0

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/tour/TourShell.tsx","../../src/tour/useTour.ts","../../src/tour/tourMachine.ts","../../src/tour/useSpotlight.ts","../../src/tour/spotlightMath.ts"],"sourcesContent":["/**\n * TourShell — the Opi onboarding tour overlay chrome.\n *\n * Deliberately shell-only, same split as OpiInsightsShell: this owns the\n * overlay, orb, narration area, step dots, and Back/Next/Skip controls.\n * The consumer (Portal) owns the step list, narration fetching (falling\n * back to the step's scripted text), and persistence. Hand-rolled overlay\n * (no Radix Dialog) to stay dependency-free, matching OpiInsightsShell's\n * own precedent rather than pulling in /primitives.\n */\nimport { useEffect, useRef, type ReactNode } from \"react\";\nimport {\n X,\n ChevronLeft,\n ChevronRight,\n ArrowRight,\n ExternalLink,\n} from \"lucide-react\";\nimport type { TourStep } from \"./types\";\n\nexport interface TourShellSkin {\n accent: string;\n overlayBg: string;\n panelBg: string;\n panelBorder: string;\n mutedText: string;\n bodyText: string;\n softText: string;\n}\n\nconst defaultSkin: TourShellSkin = {\n accent: \"#8C34E9\",\n overlayBg: \"rgba(10,14,26,0.72)\",\n panelBg: \"#0e1624\",\n panelBorder: \"1px solid #1e2738\",\n mutedText: \"#596475\",\n bodyText: \"#c0c6d0\",\n softText: \"#8890a0\",\n};\n\nexport interface TourShellProps {\n step: TourStep;\n index: number;\n total: number;\n isFirst: boolean;\n isLast: boolean;\n onNext: () => void;\n onBack: () => void;\n onDismiss: () => void;\n /** Narration to render — pass the live AI reply once resolved; while\n * pending or on failure, pass `step.fallbackText` so the tour never\n * shows a blank state. */\n narration: string;\n /** True while an AI narration pass is in flight — shows a subtle pulse, never blocks Next. */\n narrationPending?: boolean;\n /** Rendered below the narration/highlights — e.g. a docked OpiAskBar. */\n children?: ReactNode;\n skin?: TourShellSkin;\n /** Orb / avatar mark shown in the header — pass OpiOrb from the consumer. */\n orb?: ReactNode;\n}\n\n/**\n * Full-viewport dismissible overlay with a centered panel. Esc and the\n * backdrop both dismiss; focus is trapped to the panel while open.\n */\nexport function TourShell({\n step,\n index,\n total,\n isFirst,\n isLast,\n onNext,\n onBack,\n onDismiss,\n narration,\n narrationPending,\n children,\n skin = defaultSkin,\n orb,\n}: TourShellProps) {\n const panelRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") onDismiss();\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [onDismiss]);\n\n useEffect(() => {\n panelRef.current?.focus();\n }, [step.id]);\n\n return (\n <div\n className=\"fixed inset-0 z-50 flex items-center justify-center p-4\"\n style={{ background: skin.overlayBg }}\n onClick={e => {\n if (e.target === e.currentTarget) onDismiss();\n }}\n >\n <div\n ref={panelRef}\n tabIndex={-1}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label={step.label}\n className=\"w-full max-w-md rounded-xl overflow-hidden flex flex-col max-h-[85vh] outline-none\"\n style={{ background: skin.panelBg, border: skin.panelBorder }}\n >\n {/* Header */}\n <div\n className=\"flex items-center justify-between gap-3 px-5 py-4 shrink-0\"\n style={{\n background: \"linear-gradient(135deg, #2a1450 0%, #1a0e33 100%)\",\n }}\n >\n <div className=\"flex items-center gap-2.5 min-w-0\">\n {orb}\n <span className=\"text-sm font-bold text-white truncate\">\n {step.label}\n </span>\n </div>\n <button\n onClick={onDismiss}\n className=\"p-1 rounded hover:bg-white/10 transition-colors shrink-0\"\n title=\"Skip tour\"\n >\n <X size={16} className=\"text-white/70\" />\n </button>\n </div>\n\n {/* Step dots */}\n <div\n className=\"flex items-center gap-1.5 px-5 py-3 shrink-0\"\n style={{ borderBottom: skin.panelBorder }}\n >\n {Array.from({ length: total }, (_, i) => (\n <span\n key={i}\n className=\"h-1.5 rounded-full transition-all\"\n style={{\n width: i === index ? 20 : 8,\n background: i === index ? skin.accent : skin.mutedText,\n opacity: i === index ? 1 : 0.4,\n }}\n />\n ))}\n </div>\n\n {/* Body */}\n <div className=\"overflow-y-auto px-5 py-4 space-y-4\">\n <p\n className=\"text-[13px] leading-relaxed transition-opacity\"\n style={{\n color: skin.bodyText,\n opacity: narrationPending ? 0.7 : 1,\n }}\n >\n {narration}\n </p>\n\n {step.highlights && step.highlights.length > 0 && (\n <ul className=\"space-y-1.5\">\n {step.highlights.map((h, i) => (\n <li\n key={i}\n className=\"text-[12.5px] leading-relaxed pl-3 relative\"\n style={{ color: skin.softText }}\n >\n <span\n className=\"absolute left-0\"\n style={{ color: skin.mutedText }}\n >\n •\n </span>\n {h}\n </li>\n ))}\n </ul>\n )}\n\n {step.action && (\n <a\n href={step.action.href}\n target={step.action.external ? \"_blank\" : undefined}\n rel={step.action.external ? \"noopener noreferrer\" : undefined}\n className=\"inline-flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-[13px] font-semibold transition-opacity hover:opacity-90\"\n style={{ background: `${skin.accent}20`, color: skin.accent }}\n >\n {step.action.label}\n {step.action.external ? (\n <ExternalLink size={13} />\n ) : (\n <ArrowRight size={13} />\n )}\n </a>\n )}\n\n {children}\n </div>\n\n {/* Footer controls */}\n <div\n className=\"flex items-center justify-between gap-2 px-5 py-3.5 shrink-0\"\n style={{ borderTop: skin.panelBorder }}\n >\n <button\n onClick={onDismiss}\n className=\"text-[12px] font-medium transition-colors hover:underline\"\n style={{ color: skin.mutedText }}\n >\n Skip tour\n </button>\n <div className=\"flex items-center gap-2\">\n {!isFirst && (\n <button\n onClick={onBack}\n className=\"flex items-center gap-1 px-3 py-1.5 rounded-md text-[12.5px] font-medium transition-colors\"\n style={{ color: skin.bodyText, border: skin.panelBorder }}\n >\n <ChevronLeft size={13} />\n Back\n </button>\n )}\n <button\n onClick={onNext}\n className=\"flex items-center gap-1 px-3.5 py-1.5 rounded-md text-[12.5px] font-bold text-white transition-opacity hover:opacity-90\"\n style={{\n background: \"linear-gradient(135deg, #8C34E9 0%, #5B1FA6 100%)\",\n }}\n >\n {isLast ? \"Done\" : \"Next\"}\n {!isLast && <ChevronRight size={13} />}\n </button>\n </div>\n </div>\n </div>\n </div>\n );\n}\n","/**\n * useTour — pure step-index state machine for the onboarding tour.\n *\n * Deliberately dumb: it doesn't fetch steps, doesn't call any AI endpoint,\n * doesn't persist anything itself. The consumer (Portal) owns all of that\n * and is told about every state change via the on* callbacks so it can\n * write to user_settings however it likes. See OpiInsightsShell for the\n * same shell-owns-chrome/consumer-owns-data split.\n *\n * The actual transitions live in tourMachine.ts as plain functions (no\n * React import) so they're testable without a DOM renderer — this package\n * has no jsdom/@testing-library/react set up (see src/hooks/hooks.test.ts).\n * This file is just the useState wrapper around them.\n */\nimport { useCallback, useState } from \"react\";\nimport type { TourStep } from \"./types\";\nimport {\n backIndex,\n gotoIndex,\n nextIndex,\n resolveInitialIndex,\n} from \"./tourMachine\";\n\nexport interface UseTourOptions {\n /** Called whenever the current step changes (not on initial mount). */\n onStepChange?: (step: TourStep, index: number) => void;\n /** Called once when the user reaches the last step and advances past it. */\n onComplete?: () => void;\n /** Called when the user dismisses the tour before completion. */\n onDismiss?: () => void;\n /** Step id to resume on, if the tour was already in progress. */\n initialStepId?: string | null;\n}\n\nexport interface UseTourResult {\n step: TourStep;\n index: number;\n total: number;\n isFirst: boolean;\n isLast: boolean;\n next: () => void;\n back: () => void;\n goto: (stepId: string) => void;\n dismiss: () => void;\n}\n\nexport function useTour(\n steps: TourStep[],\n opts: UseTourOptions = {}\n): UseTourResult {\n if (steps.length === 0) {\n throw new Error(\"useTour requires at least one step\");\n }\n\n const [index, setIndex] = useState(() =>\n resolveInitialIndex(steps, opts.initialStepId)\n );\n\n const next = useCallback(() => {\n const result = nextIndex(steps, index);\n if (result.completed) {\n opts.onComplete?.();\n return;\n }\n setIndex(result.index);\n opts.onStepChange?.(steps[result.index], result.index);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- opts callbacks read fresh via closure; steps identity is expected stable per mount\n }, [index, steps]);\n\n const back = useCallback(() => {\n const target = backIndex(index);\n if (target === index) return;\n setIndex(target);\n opts.onStepChange?.(steps[target], target);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [index, steps]);\n\n const goto = useCallback(\n (stepId: string) => {\n const target = gotoIndex(steps, stepId, index);\n if (target === index) return;\n setIndex(target);\n opts.onStepChange?.(steps[target], target);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n },\n [steps, index]\n );\n\n const dismiss = useCallback(() => {\n opts.onDismiss?.();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return {\n step: steps[index],\n index,\n total: steps.length,\n isFirst: index === 0,\n isLast: index === steps.length - 1,\n next,\n back,\n goto,\n dismiss,\n };\n}\n","/**\n * Pure step-index transitions behind useTour — factored out so the actual\n * state machine logic is testable in a plain Node environment, without a\n * React renderer (this package has no jsdom/@testing-library/react set up;\n * see src/hooks/hooks.test.ts's note on the same limitation). useTour.ts is\n * the thin useState wrapper; this file has no React import at all.\n */\nimport type { TourStep } from \"./types\";\n\nexport interface TourMachineResult {\n index: number;\n /** True if this call reached the end and should fire onComplete instead of moving. */\n completed: boolean;\n}\n\nexport function resolveInitialIndex(\n steps: TourStep[],\n initialStepId: string | null | undefined\n): number {\n if (!initialStepId) return 0;\n const found = steps.findIndex(s => s.id === initialStepId);\n return found === -1 ? 0 : found;\n}\n\nexport function nextIndex(\n steps: TourStep[],\n current: number\n): TourMachineResult {\n if (current >= steps.length - 1) {\n return { index: current, completed: true };\n }\n return { index: current + 1, completed: false };\n}\n\nexport function backIndex(current: number): number {\n return Math.max(0, current - 1);\n}\n\nexport function gotoIndex(\n steps: TourStep[],\n stepId: string,\n current: number\n): number {\n const target = steps.findIndex(s => s.id === stepId);\n return target === -1 ? current : target;\n}\n","/**\n * useSpotlight — resolves a `data-tour-target` element and keeps its\n * measured rect fresh across resize/scroll/layout-shift, for TourShell's\n * spotlight render path.\n *\n * This is the DOM-touching half of the spotlight primitive; the actual\n * placement geometry is pure functions in spotlightMath.ts. This package has\n * no jsdom/@testing-library/react (see tourMachine.ts's own note on the same\n * gap), so this hook's correctness is exercised for real once a consumer\n * wires it up against real markup — see the R1 plan's step 3 manual-\n * verification checkpoint, not a unit test here.\n */\nimport { useEffect, useRef, useState } from \"react\";\nimport type { Rect } from \"./spotlightMath\";\n\nexport interface UseSpotlightResult {\n /** The target's current viewport-relative rect, or null while unresolved. */\n rect: Rect | null;\n /** False if no element in the DOM currently carries this selector —\n * callers must fall back to the non-spotlight rendering path, never\n * throw or render a spotlight around nothing. */\n found: boolean;\n}\n\nconst RESIZE_DEBOUNCE_MS = 100;\n\n/**\n * @param selector The `data-tour-target` attribute value to look for\n * (e.g. \"service-card-policy-deployment\"). Pass `null` to disable\n * resolution entirely (e.g. the current step has no spotlight).\n */\nexport function useSpotlight(selector: string | null): UseSpotlightResult {\n const [rect, setRect] = useState<Rect | null>(null);\n const [found, setFound] = useState(false);\n // Guards the one-time scroll-into-view per selector, per useSpotlight's own\n // doc comment: re-measuring on resize/scroll must never re-trigger a scroll.\n const scrolledForSelector = useRef<string | null>(null);\n\n useEffect(() => {\n if (!selector) {\n setRect(null);\n setFound(false);\n return;\n }\n\n let resizeTimer: ReturnType<typeof setTimeout> | undefined;\n let cancelled = false;\n\n const measure = () => {\n if (cancelled) return;\n const el = document.querySelector<HTMLElement>(\n `[data-tour-target=\"${selector}\"]`\n );\n if (!el) {\n setRect(null);\n setFound(false);\n return;\n }\n const domRect = el.getBoundingClientRect();\n setRect({\n top: domRect.top,\n left: domRect.left,\n width: domRect.width,\n height: domRect.height,\n });\n setFound(true);\n\n if (scrolledForSelector.current !== selector) {\n scrolledForSelector.current = selector;\n el.scrollIntoView({ block: \"center\", behavior: \"smooth\" });\n }\n };\n\n // Initial measure. A freshly-mounted target may not have painted yet on\n // the very first tick (e.g. right after the tour opens) — one microtask\n // deferral covers that without a fixed arbitrary delay.\n measure();\n const initialFrame = requestAnimationFrame(measure);\n\n const onResize = () => {\n if (resizeTimer) clearTimeout(resizeTimer);\n resizeTimer = setTimeout(measure, RESIZE_DEBOUNCE_MS);\n };\n // Capture phase: catches scroll on any ancestor scroll container, not\n // just document-level scroll (document-level is what ServiceHub.tsx\n // actually uses today, per the R1 plan's grounding, but capture-phase\n // costs nothing extra and keeps this hook correct if that changes).\n const onScroll = () => measure();\n\n window.addEventListener(\"resize\", onResize);\n window.addEventListener(\"scroll\", onScroll, { capture: true });\n\n // Layout shifts with no resize/scroll event — e.g. a conditionally\n // rendered sibling card appearing above the target, or the target\n // itself not existing yet at mount (e.g. the tour opened before\n // ServiceHub's card grid finished loading its services query) and\n // appearing moments later. Observing document.body rather than the\n // target's own (possibly not-yet-existent) parent means both cases are\n // covered by the same subscription with no race between \"did the\n // target exist when we looked\" and \"attach the observer\" — `measure`\n // itself is what re-checks `found` on every mutation, so a target that\n // doesn't exist yet is simply re-resolved the moment it does.\n const observer = new MutationObserver(measure);\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n });\n\n return () => {\n cancelled = true;\n cancelAnimationFrame(initialFrame);\n if (resizeTimer) clearTimeout(resizeTimer);\n window.removeEventListener(\"resize\", onResize);\n window.removeEventListener(\"scroll\", onScroll, { capture: true });\n observer?.disconnect();\n };\n }, [selector]);\n\n return { rect, found };\n}\n","/**\n * Pure geometry behind the spotlight rendering mode — no React, no DOM\n * access, just numbers in and numbers out. Factored out so it's testable\n * without jsdom (this package has none — see tourMachine.ts for the same\n * split/precedent on the step-index state machine).\n *\n * TourShell is the consumer: given a target element's measured rect (from\n * useSpotlight.ts) and the current viewport size, it needs to know (a) the\n * four backdrop-frame rectangles that surround the target without ever\n * covering it, and (b) where to place the explanation panel so it doesn't\n * overflow the viewport, honoring a preferred placement when there's room.\n */\n\nexport interface Rect {\n top: number;\n left: number;\n width: number;\n height: number;\n}\n\nexport interface Size {\n width: number;\n height: number;\n}\n\nexport type Placement = \"top\" | \"bottom\" | \"left\" | \"right\" | \"auto\";\n\n/** The four backdrop segments that frame a target rect without covering it.\n * Each is a plain rect in viewport (fixed-position) coordinates. A segment\n * with zero width or height (e.g. the target touches a viewport edge) is\n * still returned — the caller can skip rendering a degenerate rect, but\n * the geometry itself doesn't special-case it. */\nexport interface SpotlightFrame {\n top: Rect;\n bottom: Rect;\n left: Rect;\n right: Rect;\n}\n\n/** Frames `target` within a `viewport` sized 0,0 to width,height. */\nexport function computeSpotlightFrame(\n target: Rect,\n viewport: Size\n): SpotlightFrame {\n const targetBottom = target.top + target.height;\n const targetRight = target.left + target.width;\n\n return {\n // Full-width strip above the target.\n top: {\n top: 0,\n left: 0,\n width: viewport.width,\n height: Math.max(0, target.top),\n },\n // Full-width strip below the target.\n bottom: {\n top: targetBottom,\n left: 0,\n width: viewport.width,\n height: Math.max(0, viewport.height - targetBottom),\n },\n // Strip to the left of the target, spanning only the target's own row\n // (the top/bottom strips already cover the rest of those rows).\n left: {\n top: target.top,\n left: 0,\n width: Math.max(0, target.left),\n height: target.height,\n },\n // Strip to the right of the target, same row-only span as `left`.\n right: {\n top: target.top,\n left: targetRight,\n width: Math.max(0, viewport.width - targetRight),\n height: target.height,\n },\n };\n}\n\ntype ConcretePlacement = Exclude<Placement, \"auto\">;\n\nconst FALLBACK_ORDER: Record<ConcretePlacement, ConcretePlacement[]> = {\n bottom: [\"bottom\", \"top\", \"right\", \"left\"],\n top: [\"top\", \"bottom\", \"right\", \"left\"],\n right: [\"right\", \"left\", \"bottom\", \"top\"],\n left: [\"left\", \"right\", \"bottom\", \"top\"],\n};\n// \"auto\" tries the same order as the default \"bottom\" preference.\nconst AUTO_ORDER: ConcretePlacement[] = FALLBACK_ORDER.bottom;\n\nconst PANEL_GAP = 12;\n\nexport interface PanelPosition {\n top: number;\n left: number;\n placement: ConcretePlacement;\n}\n\n/**\n * Where to place a panel of `panelSize` next to `target`, preferring\n * `placement` but falling back through the other three sides (then finally\n * clamping into the viewport) if the preferred side doesn't have room.\n */\nexport function computePanelPosition(\n target: Rect,\n panelSize: Size,\n viewport: Size,\n placement: Placement = \"auto\"\n): PanelPosition {\n const order = placement === \"auto\" ? AUTO_ORDER : FALLBACK_ORDER[placement];\n\n for (const candidate of order) {\n const pos = placeAt(candidate, target, panelSize);\n if (fits(pos, panelSize, viewport)) {\n return { ...pos, placement: candidate };\n }\n }\n\n // Nothing fit cleanly (a very small viewport, or a target close to every\n // edge at once) — fall back to the first candidate's position, clamped\n // into the viewport rather than left overflowing.\n const fallback = order[0];\n const pos = placeAt(fallback, target, panelSize);\n return {\n top: clamp(pos.top, 0, Math.max(0, viewport.height - panelSize.height)),\n left: clamp(pos.left, 0, Math.max(0, viewport.width - panelSize.width)),\n placement: fallback,\n };\n}\n\nfunction placeAt(\n side: ConcretePlacement,\n target: Rect,\n panelSize: Size\n): { top: number; left: number } {\n const targetCenterX = target.left + target.width / 2;\n const targetCenterY = target.top + target.height / 2;\n\n switch (side) {\n case \"bottom\":\n return {\n top: target.top + target.height + PANEL_GAP,\n left: targetCenterX - panelSize.width / 2,\n };\n case \"top\":\n return {\n top: target.top - panelSize.height - PANEL_GAP,\n left: targetCenterX - panelSize.width / 2,\n };\n case \"right\":\n return {\n top: targetCenterY - panelSize.height / 2,\n left: target.left + target.width + PANEL_GAP,\n };\n case \"left\":\n return {\n top: targetCenterY - panelSize.height / 2,\n left: target.left - panelSize.width - PANEL_GAP,\n };\n }\n}\n\nfunction fits(\n pos: { top: number; left: number },\n panelSize: Size,\n viewport: Size\n): boolean {\n return (\n pos.top >= 0 &&\n pos.left >= 0 &&\n pos.top + panelSize.height <= viewport.height &&\n pos.left + panelSize.width <= viewport.width\n );\n}\n\nfunction clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n"],"mappings":";AAUA,SAAS,WAAW,cAA8B;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsGG,SAEE,KAFF;AAzFV,IAAM,cAA6B;AA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O;AAAA,QACL,KAAK,OAAO,MAAM,OAAO,SAAS;AAAA,QAClC,MAAM,gBAAgB,UAAU,QAAQ;AAAA,MAC1C;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,KAAK,OAAO,MAAM,UAAU,SAAS;AAAA,QACrC,MAAM,gBAAgB,UAAU,QAAQ;AAAA,MAC1C;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,KAAK,gBAAgB,UAAU,SAAS;AAAA,QACxC,MAAM,OAAO,OAAO,OAAO,QAAQ;AAAA,MACrC;AAAA,IACF,KAAK;AACH,aAAO;AAAA,QACL,KAAK,gBAAgB,UAAU,SAAS;AAAA,QACxC,MAAM,OAAO,OAAO,UAAU,QAAQ;AAAA,MACxC;AAAA,EACJ;AACF;AAEA,SAAS,KACP,KACA,WACA,UACS;AACT,SACE,IAAI,OAAO,KACX,IAAI,QAAQ,KACZ,IAAI,MAAM,UAAU,UAAU,SAAS,UACvC,IAAI,OAAO,UAAU,SAAS,SAAS;AAE3C;AAEA,SAAS,MAAM,OAAe,KAAa,KAAqB;AAC9D,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAC3C;","names":["useEffect","useRef","useState","pos"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pablo2410/shared-ui",
3
- "version": "0.19.1",
3
+ "version": "0.21.0",
4
4
  "description": "Shared UI component library for all Oplytics.digital subdomains",
5
5
  "type": "module",
6
6
  "exports": {
@@ -57,6 +57,10 @@
57
57
  "./insights": {
58
58
  "types": "./dist/insights/index.d.ts",
59
59
  "import": "./dist/insights/index.js"
60
+ },
61
+ "./tour": {
62
+ "types": "./dist/tour/index.d.ts",
63
+ "import": "./dist/tour/index.js"
60
64
  }
61
65
  },
62
66
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/catalog.ts","../src/services/crossNav.ts"],"sourcesContent":["/**\n * Shared Service Catalog — Single source of truth for all Oplytics.digital services.\n *\n * Consumed by:\n * - oplytics-subdomains (ServiceHub.tsx) — service cards, access gating\n * - oplytics-marketing-site (services.ts) — marketing pages, hero sections\n *\n * Each consumer extends with context-specific fields locally:\n * - Platform adds: route, external URL, React icon component\n * - Marketing adds: heroImage, demoImage, problem, howItWorks, results, aiFeatures\n */\n\nimport { platformUrl } from \"./platformDomain\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type ServiceStatus = \"live\" | \"in-development\" | \"coming-soon\";\nexport type ServiceCategory = \"core\" | \"hub\";\n\nexport interface ServiceDefinition {\n /** Unique identifier used for DB lookups, URL slugs, and cross-referencing */\n slug: string;\n /** Display name shown in cards, headers, and navigation */\n name: string;\n /** Short one-line value proposition */\n tagline: string;\n /** Longer description (1-2 sentences) for cards and summaries */\n description: string;\n /** Lucide icon name (string) — consumers resolve to component locally */\n icon: string;\n /** Hex accent color for cards, badges, and theming */\n accentColor: string;\n /** Current availability status */\n status: ServiceStatus;\n /** Core = standalone product, Hub = extension/add-on module */\n category: ServiceCategory;\n /**\n * Subdomain label on the platform domain (e.g. \"sqdcp\") — null if hosted\n * on portal. Full URLs are built via getServiceUrl(), which resolves the\n * platform domain at runtime (see ./platformDomain).\n */\n subdomainLabel: string | null;\n}\n\n// ---------------------------------------------------------------------------\n// Catalog\n// ---------------------------------------------------------------------------\n\nexport const SERVICE_CATALOG: ServiceDefinition[] = [\n // ─── CORE SERVICES ───\n {\n slug: \"policy-deployment\",\n name: \"Policy Deployment\",\n tagline: \"Align strategy to execution\",\n description:\n \"Hoshin Kanri and X-matrix planning. Cascade strategic objectives through every level of your organisation with live tracking and bowling charts.\",\n icon: \"Target\",\n accentColor: \"#F59E0B\",\n status: \"live\",\n category: \"core\",\n subdomainLabel: \"policy\",\n },\n {\n slug: \"sqdcp\",\n name: \"SQDCP Dashboard\",\n tagline: \"Daily management boards, digitised\",\n description:\n \"Digital SQDCP boards that drive daily accountability. Safety, Quality, Delivery, Cost, and People metrics at a glance for every team.\",\n icon: \"LayoutGrid\",\n accentColor: \"#1DB8CE\",\n status: \"live\",\n category: \"core\",\n subdomainLabel: \"sqdcp\",\n },\n {\n slug: \"oee-manager\",\n name: \"OEE Manager\",\n tagline: \"Real-time equipment effectiveness tracking\",\n description:\n \"Monitor Overall Equipment Effectiveness in real-time. Track availability, performance, and quality metrics across your entire production line.\",\n icon: \"Gauge\",\n accentColor: \"#8C34E9\",\n status: \"live\",\n category: \"core\",\n subdomainLabel: \"oeemanager\",\n },\n {\n slug: \"action-manager\",\n name: \"Action Manager\",\n tagline: \"Track every action to closure\",\n description:\n \"Capture, assign, and track corrective and preventive actions from any source. Ensure nothing falls through the cracks.\",\n icon: \"ClipboardCheck\",\n accentColor: \"#22C55E\",\n status: \"live\",\n category: \"core\",\n subdomainLabel: \"actionmanager\",\n },\n {\n slug: \"connect\",\n name: \"OplyticsConnect\",\n tagline: \"Integrate machines, sensors, and systems\",\n description:\n \"Industrial IoT connectivity layer. Connect PLCs, sensors, and legacy systems to the Oplytics platform with zero-code configuration.\",\n icon: \"Plug\",\n accentColor: \"#1DB8CE\",\n status: \"in-development\",\n category: \"core\",\n subdomainLabel: \"connect\",\n },\n\n // ─── HUB SERVICES ───\n {\n slug: \"safety-manager\",\n name: \"Safety Manager\",\n tagline: \"Proactive safety culture, powered by data\",\n description:\n \"Incident reporting, hazard tracking, safety observations, and compliance management in one unified platform.\",\n icon: \"Shield\",\n accentColor: \"#EF4444\",\n status: \"coming-soon\",\n category: \"hub\",\n subdomainLabel: \"safetymanager\",\n },\n {\n slug: \"quality-manager\",\n name: \"Quality Manager\",\n tagline: \"End-to-end quality assurance\",\n description:\n \"Non-conformance tracking, CAPA management, audit scheduling, and quality metrics dashboards.\",\n icon: \"CheckCircle\",\n accentColor: \"#22C55E\",\n status: \"coming-soon\",\n category: \"hub\",\n subdomainLabel: null,\n },\n {\n slug: \"certification-manager\",\n name: \"Certification Manager\",\n tagline: \"Stay audit-ready, always\",\n description:\n \"Manage ISO, IATF, and other certification requirements. Document control, audit trails, and compliance tracking.\",\n icon: \"Award\",\n accentColor: \"#F97316\",\n status: \"coming-soon\",\n category: \"hub\",\n subdomainLabel: null,\n },\n];\n\n// ---------------------------------------------------------------------------\n// Derived helpers\n// ---------------------------------------------------------------------------\n\nexport const coreServices = SERVICE_CATALOG.filter(s => s.category === \"core\");\nexport const hubServices = SERVICE_CATALOG.filter(s => s.category === \"hub\");\nexport const liveServices = SERVICE_CATALOG.filter(s => s.status === \"live\");\nexport const inDevServices = SERVICE_CATALOG.filter(\n s => s.status === \"in-development\"\n);\nexport const comingSoonServices = SERVICE_CATALOG.filter(\n s => s.status === \"coming-soon\"\n);\n\nexport function getServiceBySlug(slug: string): ServiceDefinition | undefined {\n return SERVICE_CATALOG.find(s => s.slug === slug);\n}\n\nexport function getServiceUrl(service: ServiceDefinition): string | null {\n if (service.subdomainLabel) {\n return platformUrl(service.subdomainLabel);\n }\n return null;\n}\n","/**\n * crossNav — build the sidebar cross-service links (service → service jump\n * without going through the Portal Service Hub).\n *\n * Visibility mirrors the Portal ServiceHub rule: platform_admin and\n * enterprise_admin see every live service; everyone else only sees the\n * services granted in the portal `user_services` table. The current service\n * never links to itself. Each link URL carries the caller's current\n * org-hierarchy selection (?oh=…) so the breadcrumb arrives pre-aligned.\n */\nimport type { OrgHierarchySelection } from \"../hierarchy/orgHierarchy\";\nimport { appendSelectionParam } from \"../hierarchy/selectionParams\";\nimport { SERVICE_CATALOG, getServiceUrl } from \"./catalog\";\n\n/** Roles that see every live service regardless of individual grants. */\nexport const ADMIN_SEE_ALL_ROLES = [\n \"platform_admin\",\n \"enterprise_admin\",\n] as const;\n\n/**\n * Legacy grant slugs → canonical catalog slugs. Auto-provisioned accounts\n * were granted \"sqdcp-logic\" while the catalog slug is \"sqdcp\".\n */\nexport const SLUG_ALIASES: Record<string, string> = {\n \"sqdcp-logic\": \"sqdcp\",\n};\n\nexport function normalizeServiceSlug(slug: string): string {\n return SLUG_ALIASES[slug] ?? slug;\n}\n\n/** Display-ready cross-service link entry. */\nexport interface CrossServiceLink {\n slug: string;\n name: string;\n /** Lucide icon name from the service catalog (consumers resolve locally). */\n icon: string;\n accentColor: string;\n /** Absolute URL including the ?oh= hierarchy selection param. */\n url: string;\n}\n\nexport interface BuildCrossServiceLinksOptions {\n /** Catalog slug of the service doing the rendering (excluded from links). */\n currentSlug: string;\n /** Grant slugs from the portal (raw — aliases are normalized here). */\n grantedSlugs: string[];\n /** Portal role of the current user (drives the admin see-all rule). */\n role?: string | null;\n /** Current org-hierarchy selection to carry across (may be empty/null). */\n selection?: OrgHierarchySelection | null;\n}\n\nexport function buildCrossServiceLinks(\n options: BuildCrossServiceLinksOptions\n): CrossServiceLink[] {\n const { currentSlug, grantedSlugs, role, selection } = options;\n\n const isAdmin =\n !!role && (ADMIN_SEE_ALL_ROLES as readonly string[]).includes(role);\n const granted = new Set(grantedSlugs.map(normalizeServiceSlug));\n const current = normalizeServiceSlug(currentSlug);\n\n return SERVICE_CATALOG.filter(\n svc =>\n svc.status === \"live\" &&\n svc.subdomainLabel !== null &&\n svc.slug !== current &&\n (isAdmin || granted.has(svc.slug))\n ).map(svc => ({\n slug: svc.slug,\n name: svc.name,\n icon: svc.icon,\n accentColor: svc.accentColor,\n url: appendSelectionParam(getServiceUrl(svc)!, selection),\n }));\n}\n"],"mappings":";;;;;;;;AAkDO,IAAM,kBAAuC;AAAA;AAAA,EAElD;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACE;AAAA,IACF,MAAM;AAAA,IACN,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,SAAS;AAAA,IACT,aACE;AAAA,IACF,MAAM;AAAA,IACN,aAAa;AAAA,IACb,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,gBAAgB;AAAA,EAClB;AAAA,EAC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