@lincyaw/aegis-ui 0.13.0 → 0.15.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.
Files changed (44) hide show
  1. package/dist/components/ui/CommitGraph.cjs +1 -1
  2. package/dist/components/ui/CommitGraph.cjs.map +1 -1
  3. package/dist/components/ui/CommitGraph.d.ts +23 -5
  4. package/dist/components/ui/CommitGraph.js +236 -200
  5. package/dist/components/ui/CommitGraph.js.map +1 -1
  6. package/dist/components/ui/DetailBeside.cjs +1 -1
  7. package/dist/components/ui/DetailBeside.cjs.map +1 -1
  8. package/dist/components/ui/DetailBeside.d.ts +31 -9
  9. package/dist/components/ui/DetailBeside.js +75 -71
  10. package/dist/components/ui/DetailBeside.js.map +1 -1
  11. package/dist/components/ui/RegionMap.cjs +2 -0
  12. package/dist/components/ui/RegionMap.cjs.map +1 -0
  13. package/dist/components/ui/RegionMap.d.ts +53 -0
  14. package/dist/components/ui/RegionMap.js +173 -0
  15. package/dist/components/ui/RegionMap.js.map +1 -0
  16. package/dist/components/ui/RollingValue.cjs.map +1 -1
  17. package/dist/components/ui/RollingValue.d.ts +1 -2
  18. package/dist/components/ui/RollingValue.js.map +1 -1
  19. package/dist/components/ui/ServiceMap.cjs +1 -1
  20. package/dist/components/ui/ServiceMap.cjs.map +1 -1
  21. package/dist/components/ui/ServiceMap.d.ts +2 -1
  22. package/dist/components/ui/ServiceMap.js +233 -237
  23. package/dist/components/ui/ServiceMap.js.map +1 -1
  24. package/dist/components/ui/Timeline.cjs +1 -1
  25. package/dist/components/ui/Timeline.cjs.map +1 -1
  26. package/dist/components/ui/Timeline.d.ts +16 -1
  27. package/dist/components/ui/Timeline.js +115 -45
  28. package/dist/components/ui/Timeline.js.map +1 -1
  29. package/dist/components/ui/TraceTree.cjs +1 -1
  30. package/dist/components/ui/TraceTree.cjs.map +1 -1
  31. package/dist/components/ui/TraceTree.d.ts +8 -1
  32. package/dist/components/ui/TraceTree.js +198 -175
  33. package/dist/components/ui/TraceTree.js.map +1 -1
  34. package/dist/components/ui/index.d.ts +5 -1
  35. package/dist/components/ui/workStatus.cjs +2 -0
  36. package/dist/components/ui/workStatus.cjs.map +1 -0
  37. package/dist/components/ui/workStatus.d.ts +15 -0
  38. package/dist/components/ui/workStatus.js +18 -0
  39. package/dist/components/ui/workStatus.js.map +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.js +175 -171
  42. package/dist/index.js.map +1 -1
  43. package/dist/style.css +1 -1
  44. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DetailBeside.js","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a\n * Panel say. The detail follows the row it draws selected.\n */\n children: ReactNode;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection, the\n * selection changes or the selected row is clicked, the page scrolls at\n * once, as little as it takes to show the row and the detail whole, and\n * again whenever the list or the detail changes size, until the viewer\n * scrolls. The wrapper is `aria-busy` while the selected row is still on\n * its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const moved = row !== null && row === rowRef.current;\n rowRef.current = row;\n if (moved) {\n place();\n } else if (row === null) {\n followRef.current = false;\n setBusy(false);\n } else {\n revealSoon();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n useIsomorphicLayoutEffect(place);\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","place","useCallback","box","rowBox","spacer","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","moved","awaitRow","useIsomorphicLayoutEffect","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":";;;;;;;AAgDA,MAAMA,IAAe,sBAMfC,IAAgBC,EAAyB,IAAI;AAOnD,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACQ;AACR,QAAMC,IAAMD,EAAK,MAAMD,GACjBG,IACJN,EAAI,MAAMK,IAAML,EAAI,MAAMK,IAAM,KAAK,IAAIL,EAAI,SAASI,EAAK,QAAQ,CAAC;AACtE,SAAO,KAAK,IAAIE,GAAOL,IAAUC,IAASE,EAAK,MAAM;AACvD;AAGA,SAASG,EAAa,EAAE,QAAAC,KAAiD;AACvE,QAAMC,IAASC,EAAWb,CAAa;AACvC,SACE,gBAAAc,EAAC,SAAI,KAAKH,GAAQ,WAAU,+BAA8B,MAAK,SAC5D,UAAAC,EAAA,CACH;AAEJ;AAgBO,SAASG,GAAa;AAAA,EAC3B,SAAAC;AAAA,EACA,QAAAJ;AAAA,EACA,UAAAK;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAActB,CAAY,GACnC,CAACuB,GAAMC,CAAO,IAAIC,EAAS,EAAK,GAChCC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAuB,IAAI,GACvCE,IAAYF,EAAuB,IAAI,GACvCG,IAASH,EAA2B,IAAI,GAExCI,IAAYJ,EAAO,EAAK,GACxBK,IAAgBL,EAAO,CAAC,GAMxBM,IAAQC,EAAY,MAAM;AAC9B,UAAM9B,IAAM0B,EAAO,SACbK,IAAMN,EAAU;AACtB,QAAIzB,MAAQ,QAAQ+B,MAAQ;AAC1B;AAEF,UAAMC,IAAShC,EAAI,sBAAA,GACbiC,IAAST,EAAU;AACzB,QAAIS,MAAW;AACb,MAAAF,EAAI,MAAM;AAAA,QACR;AAAA,QACA,GAAG,OAAOC,EAAO,MAAM,CAAC;AAAA,MAAA;AAAA,SAErB;AACL,YAAM3B,IAAM4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AS;IAChD,CAACX,GAAUE,GAAUS,CAAM;AAAA,EAAA,GAEvBG,IACJ,gBAAA3C,EAAC4C,EAAyB,UAAzB,EAAkC,OAAO,MACvC,UAAA9C,GACH,GAGI+C,IAAM,CAAC,uBAAuBxC,KAAa,EAAE,EAChD,OAAO,OAAO,EACd,KAAK,GAAG;AAEX,SACE,gBAAAL,EAAC4C,EAAyB,UAAzB,EAAkC,OAAOF,GACxC,UAAA,gBAAA1C,EAACd,EAAc,UAAd,EAAuB,OAAOyD,GAC7B,UAAA,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWD;AAAA,MACX,OAAO,EAAE,iCAAiC3C,EAAA;AAAA,MAC1C,aAAWM,KAAQ;AAAA,MAEnB,UAAA;AAAA,QAAA,gBAAAR,EAAC,OAAA,EAAI,KAAKW,GAAS,WAAU,6BAC1B,UAAAR,GACH;AAAA,QACC,CAACG,KACA,gBAAAwC,EAAC,OAAA,EAAI,WAAU,6BACb,UAAA;AAAA,UAAA,gBAAA9C,EAAC,OAAA,EAAI,KAAKa,EAAA,CAAW;AAAA,4BACpB,OAAA,EAAI,KAAKC,GAAW,WAAU,+BAC5B,UAAA6B,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"DetailBeside.js","sources":["../../../src/components/ui/DetailBeside.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../../hooks/useIsomorphicLayoutEffect';\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport {\n type ViewBounds,\n scrollerOf,\n viewBoundsOf,\n} from '../../lib/scrollView';\nimport './DetailBeside.css';\nimport {\n type SelectedRowDetail,\n SelectedRowDetailContext,\n} from './selectedRowDetail';\n\nexport interface DetailBesideProps {\n /**\n * `grid-template-columns` of the list and the detail above 768 px, e.g.\n * `'3fr 2fr'`.\n */\n columns: string;\n /**\n * The selected item's detail: one element, such as a `Panel` titled with\n * the item's name. It is never taller than the view, so a long Panel\n * scrolls its body. Render it anew from the host's data whenever that\n * data changes: that render tells DetailBeside the change was new data,\n * so the page stays where it is. A detail that fetches its own data and\n * redraws without this host rendering leaves the page following the row,\n * and its next change of size scrolls the page.\n */\n detail: ReactNode;\n /**\n * The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a\n * Panel say. The detail follows the row it draws selected. Like\n * `detail`, render it anew from the host's data whenever that data\n * changes, so the page stays where it is on new data; a list that fetches\n * its own data and redraws without this host rendering leaves the page\n * following the row, and its next change of size scrolls the page.\n */\n children: ReactNode;\n /**\n * The selection as the page's address names it, or null where the\n * address names none and the list shows a default. It changes only by\n * the viewer's doing: a click, a key, a link, back or forward. The page\n * scrolls to the selected row when this changes, and on the first\n * placement after mount; a row that comes into place for new data, such\n * as a default the data moved, is only levelled with.\n */\n revealKey: string | null;\n /** The element that scrolls the page; omitted or null means the viewport. */\n scrollContainer?: HTMLElement | null;\n className?: string;\n}\n\nconst NARROW_QUERY = '(max-width: 768px)';\n\n/**\n * The detail as the inline slot draws it. It is kept out of the context the\n * lists read, so a new detail re-renders the slot and not the list.\n */\nconst DetailContext = createContext<ReactNode>(null);\n\n/**\n * How far to scroll so the row is in the view, clear of the `inset` at the\n * view's top, and the detail, whose top can rise no higher than `ceiling`,\n * fits above the view's bottom.\n */\nfunction revealDistance(\n row: DOMRect,\n ceiling: number,\n height: number,\n inset: number,\n view: ViewBounds,\n): number {\n const top = view.top + inset;\n const toRow =\n row.top < top ? row.top - top : Math.max(row.bottom - view.bottom, 0);\n return Math.max(toRow, ceiling + height - view.bottom);\n}\n\n/** The detail right after the selected row, at 768 px and below. */\nfunction InlineDetail({ boxRef }: { boxRef: RefObject<HTMLDivElement> }) {\n const detail = useContext(DetailContext);\n return (\n <div ref={boxRef} className=\"aegis-detail-beside__inline\" role=\"group\">\n {detail}\n </div>\n );\n}\n\n/**\n * A tree, table or map with the selected item's detail beside it. Above\n * 768 px the detail stands in a column on the right, level with the\n * selected row: when the row is too low for it, its bottom meets the\n * view's bottom, and while the page scrolls it stays in the view below\n * the header. At 768 px and below the list draws the detail right after\n * the selected row, the rows that follow under it; a map draws it over\n * the map, under the node. When the page opens with a selection,\n * `revealKey` changes or the viewer clicks the selected row, the page\n * scrolls at once, as little as it takes to show the row and the detail\n * whole, and again whenever the list or the detail changes size, until the\n * viewer scrolls or the host renders a new list or detail. Any other\n * placement, such as new data moving the selection or the rows, levels\n * the detail with its row by the same rule and leaves the page where it\n * is; the browser's scroll anchoring can still move it when rows arrive\n * above the view, unless the host sets `overflow-anchor: none` on its\n * scroller. The wrapper is `aria-busy` while a selected row it reveals is\n * still on its way.\n */\nexport function DetailBeside({\n columns,\n detail,\n children,\n revealKey,\n scrollContainer = null,\n className,\n}: DetailBesideProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const [busy, setBusy] = useState(false);\n const listRef = useRef<HTMLDivElement>(null);\n const spacerRef = useRef<HTMLDivElement>(null);\n const detailRef = useRef<HTMLDivElement>(null);\n const rowRef = useRef<HTMLElement | null>(null);\n /** Whether the page is still where the last reveal left it. */\n const followRef = useRef(false);\n const revealedAtRef = useRef(0);\n /** The latest render's revealKey, and the last reveal's: undefined before the first. */\n const revealKeyRef = useRef(revealKey);\n const revealedKeyRef = useRef<string | null | undefined>(undefined);\n /** The latest render's list and detail, which change when the host renders them anew. */\n const shownRef = useRef({ children, detail });\n\n /**\n * Sets the detail level with the row: above 768 px through the spacer's\n * height, at and below by telling the inline detail how tall the row is.\n */\n const place = useCallback(() => {\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n if (spacer === null) {\n box.style.setProperty(\n '--aegis-detail-beside-row-height',\n `${String(rowBox.height)}px`,\n );\n } else {\n const top = spacer.getBoundingClientRect().top;\n spacer.style.height = `${String(Math.max(rowBox.top - top, 0))}px`;\n }\n }, []);\n\n /** Places the row and scrolls as little as it takes to show it and its detail whole. */\n const reveal = useCallback(() => {\n place();\n const row = rowRef.current;\n const box = detailRef.current;\n if (row === null || box === null) {\n return;\n }\n const rowBox = row.getBoundingClientRect();\n const spacer = spacerRef.current;\n const distance = revealDistance(\n rowBox,\n spacer === null ? rowBox.bottom : spacer.getBoundingClientRect().top,\n box.getBoundingClientRect().height,\n parseFloat(getComputedStyle(box).scrollMarginTop),\n viewBoundsOf(scrollContainer),\n );\n const scroller = scrollerOf(scrollContainer);\n if (Math.abs(distance) >= 1) {\n scroller.scrollBy({ top: distance, behavior: 'instant' });\n }\n revealedAtRef.current = scroller.scrollTop;\n }, [place, scrollContainer]);\n\n // A list places its row while React attaches refs, before the detail's\n // own ref is in and before the re-renders its layout effects ask for,\n // so the reveal waits for the commit to finish.\n const revealSoon = useCallback(() => {\n revealedKeyRef.current = revealKeyRef.current;\n followRef.current = true;\n setBusy(true);\n queueMicrotask(() => {\n reveal();\n setBusy(false);\n });\n }, [reveal]);\n\n // A row placed while a reveal is due is revealed; any other is levelled\n // with, and a new one ends following.\n const placeRow = useCallback(\n (row: HTMLElement | null) => {\n const fresh = row !== rowRef.current;\n rowRef.current = row;\n if (row === null) {\n followRef.current = false;\n setBusy(false);\n } else if (revealedKeyRef.current !== revealKeyRef.current) {\n revealSoon();\n } else {\n if (fresh) {\n followRef.current = false;\n }\n place();\n }\n },\n [place, revealSoon],\n );\n\n const awaitRow = useCallback(() => {\n setBusy(true);\n }, []);\n\n // Runs after the lists have placed their rows in this commit, so a new\n // revealKey reveals the row it selects. A render by the host without one\n // ends following.\n useIsomorphicLayoutEffect(() => {\n const rendered =\n shownRef.current.children !== children ||\n shownRef.current.detail !== detail;\n shownRef.current = { children, detail };\n revealKeyRef.current = revealKey;\n if (revealedKeyRef.current !== revealKey && rowRef.current !== null) {\n revealSoon();\n } else {\n if (rendered) {\n followRef.current = false;\n }\n place();\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n const list = listRef.current;\n if (list === null) {\n return undefined;\n }\n const observer = new ResizeObserver(() => {\n if (followRef.current) {\n reveal();\n } else {\n place();\n }\n });\n // At 768 px and below the detail lies inside the list.\n for (const box of narrow ? [list] : [list, detailRef.current]) {\n if (box !== null) {\n observer.observe(box);\n }\n }\n const activate = (event: MouseEvent): void => {\n if (\n event.target instanceof Node &&\n rowRef.current?.contains(event.target)\n ) {\n revealSoon();\n }\n };\n list.addEventListener('click', activate);\n return () => {\n observer.disconnect();\n list.removeEventListener('click', activate);\n };\n }, [narrow, place, reveal, revealSoon]);\n\n useEffect(() => {\n const scroller = scrollerOf(scrollContainer);\n const target = scrollContainer ?? window;\n const scrolled = (): void => {\n if (Math.abs(scroller.scrollTop - revealedAtRef.current) >= 1) {\n followRef.current = false;\n }\n };\n target.addEventListener('scroll', scrolled, { passive: true });\n return () => {\n target.removeEventListener('scroll', scrolled);\n };\n }, [scrollContainer]);\n\n const inline = useMemo(\n () => (narrow ? <InlineDetail boxRef={detailRef} /> : null),\n [narrow],\n );\n const slot = useMemo(\n (): SelectedRowDetail => ({ placeRow, awaitRow, inline }),\n [placeRow, awaitRow, inline],\n );\n const isolated = (\n <SelectedRowDetailContext.Provider value={null}>\n {detail}\n </SelectedRowDetailContext.Provider>\n );\n\n const cls = ['aegis-detail-beside', className ?? '']\n .filter(Boolean)\n .join(' ');\n\n return (\n <SelectedRowDetailContext.Provider value={slot}>\n <DetailContext.Provider value={isolated}>\n <div\n className={cls}\n style={{ '--aegis-detail-beside-columns': columns } as CSSProperties}\n aria-busy={busy || undefined}\n >\n <div ref={listRef} className=\"aegis-detail-beside__list\">\n {children}\n </div>\n {!narrow && (\n <div className=\"aegis-detail-beside__side\">\n <div ref={spacerRef} />\n <div ref={detailRef} className=\"aegis-detail-beside__detail\">\n {isolated}\n </div>\n </div>\n )}\n </div>\n </DetailContext.Provider>\n </SelectedRowDetailContext.Provider>\n );\n}\n"],"names":["NARROW_QUERY","DetailContext","createContext","revealDistance","row","ceiling","height","inset","view","top","toRow","InlineDetail","boxRef","detail","useContext","jsx","DetailBeside","columns","children","revealKey","scrollContainer","className","narrow","useMediaQuery","busy","setBusy","useState","listRef","useRef","spacerRef","detailRef","rowRef","followRef","revealedAtRef","revealKeyRef","revealedKeyRef","shownRef","place","useCallback","box","rowBox","spacer","reveal","distance","viewBoundsOf","scroller","scrollerOf","revealSoon","placeRow","fresh","awaitRow","useIsomorphicLayoutEffect","rendered","list","observer","activate","event","useEffect","target","scrolled","inline","useMemo","slot","isolated","SelectedRowDetailContext","cls","jsxs"],"mappings":";;;;;;;AAiEA,MAAMA,IAAe,sBAMfC,IAAgBC,EAAyB,IAAI;AAOnD,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACQ;AACR,QAAMC,IAAMD,EAAK,MAAMD,GACjBG,IACJN,EAAI,MAAMK,IAAML,EAAI,MAAMK,IAAM,KAAK,IAAIL,EAAI,SAASI,EAAK,QAAQ,CAAC;AACtE,SAAO,KAAK,IAAIE,GAAOL,IAAUC,IAASE,EAAK,MAAM;AACvD;AAGA,SAASG,EAAa,EAAE,QAAAC,KAAiD;AACvE,QAAMC,IAASC,EAAWb,CAAa;AACvC,SACE,gBAAAc,EAAC,SAAI,KAAKH,GAAQ,WAAU,+BAA8B,MAAK,SAC5D,UAAAC,EAAA,CACH;AAEJ;AAqBO,SAASG,GAAa;AAAA,EAC3B,SAAAC;AAAA,EACA,QAAAJ;AAAA,EACA,UAAAK;AAAA,EACA,WAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,WAAAC;AACF,GAAsB;AACpB,QAAMC,IAASC,EAAcvB,CAAY,GACnC,CAACwB,GAAMC,CAAO,IAAIC,EAAS,EAAK,GAChCC,IAAUC,EAAuB,IAAI,GACrCC,IAAYD,EAAuB,IAAI,GACvCE,IAAYF,EAAuB,IAAI,GACvCG,IAASH,EA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iCAAiChD,EAAA;AAAA,MAC1C,aAAWO,KAAQ;AAAA,MAEnB,UAAA;AAAA,QAAA,gBAAAT,EAAC,OAAA,EAAI,KAAKY,GAAS,WAAU,6BAC1B,UAAAT,GACH;AAAA,QACC,CAACI,KACA,gBAAA4C,EAAC,OAAA,EAAI,WAAU,6BACb,UAAA;AAAA,UAAA,gBAAAnD,EAAC,OAAA,EAAI,KAAKc,EAAA,CAAW;AAAA,4BACpB,OAAA,EAAI,KAAKC,GAAW,WAAU,+BAC5B,UAAAiC,EAAA,CACH;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,GAGN,EAAA,CACF;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),m=require("react");;/* empty css */const K=require("./RollingValue.cjs"),L=require("./StatusDot.cjs"),O=require("./linkComponent.cjs"),B=require("./workStatus.cjs"),F=4;function $(u){const n=new Map;u.forEach(r=>{n.set(r.id,{region:r,parent:null,children:[],depth:0,leaves:1})});const o=[];n.forEach(r=>{const d=r.region.parentId,c=d?n.get(d):void 0;let l=c;for(;l!==void 0&&l!==r;)l=l.parent??void 0;c&&l===void 0?(r.parent=c,c.children.push(r)):o.push(r)});const p=(r,d)=>(r.depth=d,r.leaves=r.children.length?r.children.reduce((c,l)=>c+p(l,d+1),0):1,r.leaves);return o.forEach(r=>{p(r,0)}),o}function S(u,n=[]){return u.forEach(o=>{n.push(o),S(o.children,n)}),n}function P({regions:u,ariaLabel:n,selectedId:o,onSelect:p,linkComponent:r=O.DefaultLink,className:d,style:c}){const l=m.useId(),x=m.useRef(new Map),f=m.useMemo(()=>$(u),[u]),g=m.useMemo(()=>S(f),[f]),[q,w]=m.useState(void 0),M=e=>e===void 0?-1:g.findIndex(i=>i.region.id===e),y=M(q),D=g[y>=0?y:Math.max(M(o),0)]?.region.id,h=e=>{e&&(w(e.region.id),x.current.get(e.region.id)?.focus())},C=(e,i)=>{if(e.target!==e.currentTarget)return;const _=g.indexOf(i);switch(e.key){case"ArrowDown":h(g[_+1]);break;case"ArrowUp":h(g[_-1]);break;case"ArrowRight":h(i.children[0]);break;case"ArrowLeft":h(i.parent);break;case"Home":h(g[0]);break;case"End":h(g[g.length-1]);break;case"Enter":i.region.to!==void 0?e.currentTarget.querySelector(":scope > .aegis-region-map__head .aegis-region-map__label a")?.click():p?.(i.region);break;case" ":p?.(i.region);break;default:return}e.preventDefault()},E=(e,i)=>{!(e.target instanceof Element)||e.target.closest('[role="treeitem"]')!==e.currentTarget||(e.ctrlKey||e.metaKey||e.shiftKey)&&e.target.closest(".aegis-region-map__label a")!==null||p?.(i.region)},N=(e,i,_)=>{const{region:a}=e,b=a.id===o,k=e.children.length>0,j=a.count!==void 0&&a.count!=="",v=a.state!==void 0&&a.state!==null,I=`${l}-${a.id}-facts`,R=Math.min(Math.ceil(Math.sqrt(e.leaves)),F),T=["aegis-region-map__tile",`aegis-region-map__tile--depth-${String(Math.min(e.depth,3))}`,k?"":"aegis-region-map__tile--leaf",b?"aegis-region-map__tile--selected":""].filter(Boolean).join(" ");return t.jsxs("div",{ref:s=>{s?x.current.set(a.id,s):x.current.delete(a.id)},className:T,style:{"--aegis-region-map-weight":e.leaves,"--aegis-region-map-columns":R},role:"treeitem","aria-label":a.ariaLabel??a.label,"aria-describedby":j||v?I:void 0,"aria-level":e.depth+1,"aria-posinset":i,"aria-setsize":_,"aria-expanded":k?!0:void 0,"aria-selected":b,tabIndex:a.id===D?0:-1,onClick:s=>{E(s,e)},onKeyDown:s=>{C(s,e)},onFocus:s=>{s.target===s.currentTarget&&w(a.id)},children:[t.jsxs("div",{className:["aegis-region-map__head",e.depth===0?"aegis-region-map__head--top":"",b?"aegis-region-map__head--selected":""].filter(Boolean).join(" "),children:[t.jsxs("span",{className:"aegis-region-map__name",children:[a.status!==void 0&&t.jsx(L.StatusDot,{...B.workStatusDot(a.status,b)}),t.jsx("span",{className:"aegis-region-map__label",children:a.to===void 0?a.label:t.jsx(r,{to:a.to,className:"aegis-region-map__link",tabIndex:-1,children:a.label})})]}),(j||v)&&t.jsxs("span",{id:I,className:"aegis-region-map__facts",children:[j&&t.jsx("span",{className:"aegis-region-map__count",children:t.jsx(K.RollingValue,{value:a.count})}),v&&t.jsx("span",{className:"aegis-region-map__state",children:a.state})]})]}),k&&t.jsx("div",{className:"aegis-region-map__regions",role:"group",children:e.children.map((s,A)=>N(s,A+1,e.children.length))})]},a.id)};return t.jsx("div",{className:["aegis-region-map",d??""].filter(Boolean).join(" "),style:c,role:"tree","aria-label":n,children:f.map((e,i)=>N(e,i+1,f.length))})}exports.RegionMap=P;
2
+ //# sourceMappingURL=RegionMap.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegionMap.cjs","sources":["../../../src/components/ui/RegionMap.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport './RegionMap.css';\nimport { RollingValue } from './RollingValue';\nimport { StatusDot } from './StatusDot';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\nimport { type WorkStatus, workStatusDot } from './workStatus';\n\n/**\n * The state of a region, drawn as a dot before its label. `active` is work\n * in progress: the ink dot pulses, as in `ServiceMap`.\n */\nexport type RegionMapStatus = WorkStatus;\n\nexport interface RegionMapRegion {\n id: string;\n /** The region it lies in. A region whose `parentId` names no region is a top-level region. */\n parentId?: string | null;\n label: string;\n /** The tile's accessible name. Default: `label`. */\n ariaLabel?: string;\n /** Default: no dot. */\n status?: RegionMapStatus;\n /** A number at the end of the tile's head, rolling to a new value. */\n count?: number | string;\n /**\n * A state at the end of the tile's head, e.g. a `Chip`. Give a Chip in it\n * `inverted` while the region is selected.\n */\n state?: ReactNode;\n /**\n * Makes the label a link to this destination. The tile stays the map's tab\n * stop: the link is not a tab stop, and Enter on the tile follows it.\n */\n to?: string;\n}\n\nexport interface RegionMapProps {\n /** The regions in any order; each nests inside the region its `parentId` names. */\n regions: RegionMapRegion[];\n /** The map's accessible name. */\n ariaLabel: string;\n /** The selected region, drawn inverted. */\n selectedId?: string;\n onSelect?: (region: RegionMapRegion) => void;\n /** Renders the labels of regions with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n style?: CSSProperties;\n}\n\ninterface Node {\n region: RegionMapRegion;\n parent: Node | null;\n children: Node[];\n depth: number;\n leaves: number;\n}\n\nconst MAX_COLUMNS = 4;\n\nfunction buildForest(regions: RegionMapRegion[]): Node[] {\n const byId = new Map<string, Node>();\n regions.forEach((region) => {\n byId.set(region.id, {\n region,\n parent: null,\n children: [],\n depth: 0,\n leaves: 1,\n });\n });\n const roots: Node[] = [];\n byId.forEach((node) => {\n const pid = node.region.parentId;\n const parent = pid ? byId.get(pid) : undefined;\n // A parent that is the region itself, or lies inside it, would close a\n // cycle; the region becomes a top-level one instead.\n let ancestor = parent;\n while (ancestor !== undefined && ancestor !== node) {\n ancestor = ancestor.parent ?? undefined;\n }\n if (parent && ancestor === undefined) {\n node.parent = parent;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n });\n const place = (node: Node, depth: number): number => {\n node.depth = depth;\n node.leaves = node.children.length\n ? node.children.reduce((sum, child) => sum + place(child, depth + 1), 0)\n : 1;\n return node.leaves;\n };\n roots.forEach((root) => {\n place(root, 0);\n });\n return roots;\n}\n\nfunction preorder(nodes: Node[], out: Node[] = []): Node[] {\n nodes.forEach((node) => {\n out.push(node);\n preorder(node.children, out);\n });\n return out;\n}\n\n/**\n * A tree of regions drawn as nested tiles that fill their container, like a\n * territory map: each region holds the tiles of the regions inside it, and\n * a region with more regions under it takes more room. Each tile carries a\n * status dot, a label that may be a link, a count and a state slot; the\n * selected tile is inverted. For assistive technology the map is a tree\n * whose regions read in order, each named by its label and described by\n * its count and state.\n */\nexport function RegionMap({\n regions,\n ariaLabel,\n selectedId,\n onSelect,\n linkComponent: Link = DefaultLink,\n className,\n style,\n}: RegionMapProps) {\n const idPrefix = useId();\n const tiles = useRef(new Map<string, HTMLDivElement>());\n const roots = useMemo(() => buildForest(regions), [regions]);\n const order = useMemo(() => preorder(roots), [roots]);\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n\n const indexOf = (id: string | undefined): number =>\n id === undefined ? -1 : order.findIndex((n) => n.region.id === id);\n const focusedIndex = indexOf(focusedId);\n const tabStopId =\n order[focusedIndex >= 0 ? focusedIndex : Math.max(indexOf(selectedId), 0)]\n ?.region.id;\n\n const focusTile = (node: Node | null | undefined): void => {\n if (!node) {\n return;\n }\n setFocusedId(node.region.id);\n tiles.current.get(node.region.id)?.focus();\n };\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLDivElement>,\n node: Node,\n ): void => {\n if (event.target !== event.currentTarget) {\n return;\n }\n const index = order.indexOf(node);\n switch (event.key) {\n case 'ArrowDown':\n focusTile(order[index + 1]);\n break;\n case 'ArrowUp':\n focusTile(order[index - 1]);\n break;\n case 'ArrowRight':\n focusTile(node.children[0]);\n break;\n case 'ArrowLeft':\n focusTile(node.parent);\n break;\n case 'Home':\n focusTile(order[0]);\n break;\n case 'End':\n focusTile(order[order.length - 1]);\n break;\n // The link's click reaches the tile, which selects it too.\n case 'Enter':\n if (node.region.to !== undefined) {\n event.currentTarget\n .querySelector<HTMLElement>(\n ':scope > .aegis-region-map__head .aegis-region-map__label a',\n )\n ?.click();\n } else {\n onSelect?.(node.region);\n }\n break;\n case ' ':\n onSelect?.(node.region);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const handleClick = (event: MouseEvent<HTMLDivElement>, node: Node): void => {\n // Only the innermost tile under the pointer takes the click.\n if (\n !(event.target instanceof Element) ||\n event.target.closest('[role=\"treeitem\"]') !== event.currentTarget\n ) {\n return;\n }\n // A modified click opens the label's link elsewhere and leaves this\n // page's selection alone.\n if (\n (event.ctrlKey || event.metaKey || event.shiftKey) &&\n event.target.closest('.aegis-region-map__label a') !== null\n ) {\n return;\n }\n onSelect?.(node.region);\n };\n\n const renderTile = (\n node: Node,\n position: number,\n siblings: number,\n ): ReactNode => {\n const { region } = node;\n const selected = region.id === selectedId;\n const hasChildren = node.children.length > 0;\n const hasCount = region.count !== undefined && region.count !== '';\n const hasState = region.state !== undefined && region.state !== null;\n const factsId = `${idPrefix}-${region.id}-facts`;\n const columns = Math.min(Math.ceil(Math.sqrt(node.leaves)), MAX_COLUMNS);\n const cls = [\n 'aegis-region-map__tile',\n `aegis-region-map__tile--depth-${String(Math.min(node.depth, 3))}`,\n hasChildren ? '' : 'aegis-region-map__tile--leaf',\n selected ? 'aegis-region-map__tile--selected' : '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div\n key={region.id}\n ref={(element) => {\n if (element) {\n tiles.current.set(region.id, element);\n } else {\n tiles.current.delete(region.id);\n }\n }}\n className={cls}\n style={\n {\n '--aegis-region-map-weight': node.leaves,\n '--aegis-region-map-columns': columns,\n } as CSSProperties\n }\n role=\"treeitem\"\n aria-label={region.ariaLabel ?? region.label}\n aria-describedby={hasCount || hasState ? factsId : undefined}\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-expanded={hasChildren ? true : undefined}\n aria-selected={selected}\n tabIndex={region.id === tabStopId ? 0 : -1}\n onClick={(event) => {\n handleClick(event, node);\n }}\n onKeyDown={(event) => {\n handleKeyDown(event, node);\n }}\n onFocus={(event) => {\n if (event.target === event.currentTarget) {\n setFocusedId(region.id);\n }\n }}\n >\n <div\n className={[\n 'aegis-region-map__head',\n node.depth === 0 ? 'aegis-region-map__head--top' : '',\n selected ? 'aegis-region-map__head--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <span className=\"aegis-region-map__name\">\n {region.status !== undefined && (\n <StatusDot {...workStatusDot(region.status, selected)} />\n )}\n <span className=\"aegis-region-map__label\">\n {region.to === undefined ? (\n region.label\n ) : (\n <Link\n to={region.to}\n className=\"aegis-region-map__link\"\n tabIndex={-1}\n >\n {region.label}\n </Link>\n )}\n </span>\n </span>\n {(hasCount || hasState) && (\n <span id={factsId} className=\"aegis-region-map__facts\">\n {hasCount && (\n <span className=\"aegis-region-map__count\">\n <RollingValue value={region.count} />\n </span>\n )}\n {hasState && (\n <span className=\"aegis-region-map__state\">{region.state}</span>\n )}\n </span>\n )}\n </div>\n {hasChildren && (\n <div className=\"aegis-region-map__regions\" role=\"group\">\n {node.children.map((child, index) =>\n renderTile(child, index + 1, node.children.length),\n )}\n </div>\n )}\n </div>\n );\n };\n\n return (\n <div\n className={['aegis-region-map', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={style}\n role=\"tree\"\n aria-label={ariaLabel}\n >\n {roots.map((root, index) => renderTile(root, index + 1, roots.length))}\n </div>\n );\n}\n"],"names":["MAX_COLUMNS","buildForest","regions","byId","region","roots","node","pid","parent","ancestor","place","depth","sum","child","root","preorder","nodes","out","RegionMap","ariaLabel","selectedId","onSelect","Link","DefaultLink","className","style","idPrefix","useId","tiles","useRef","useMemo","order","focusedId","setFocusedId","useState","indexOf","id","n","focusedIndex","tabStopId","focusTile","handleKeyDown","event","index","handleClick","renderTile","position","siblings","selected","hasChildren","hasCount","hasState","factsId","columns","cls","jsxs","element","jsx","StatusDot","workStatusDot","RollingValue"],"mappings":"ySAoEMA,EAAc,EAEpB,SAASC,EAAYC,EAAoC,CACvD,MAAMC,MAAW,IACjBD,EAAQ,QAASE,GAAW,CAC1BD,EAAK,IAAIC,EAAO,GAAI,CAClB,OAAAA,EACA,OAAQ,KACR,SAAU,CAAA,EACV,MAAO,EACP,OAAQ,CAAA,CACT,CACH,CAAC,EACD,MAAMC,EAAgB,CAAA,EACtBF,EAAK,QAASG,GAAS,CACrB,MAAMC,EAAMD,EAAK,OAAO,SAClBE,EAASD,EAAMJ,EAAK,IAAII,CAAG,EAAI,OAGrC,IAAIE,EAAWD,EACf,KAAOC,IAAa,QAAaA,IAAaH,GAC5CG,EAAWA,EAAS,QAAU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AG,EAEzDS,EAAAA,IAAC,QAAK,UAAU,0BACb,WAAO,KAAO,OACbrD,EAAO,MAEPqD,EAAAA,IAACnC,EAAA,CACC,GAAIlB,EAAO,GACX,UAAU,yBACV,SAAU,GAET,SAAAA,EAAO,KAAA,CAAA,CACV,CAEJ,CAAA,EACF,GACE8C,GAAYC,IACZI,EAAAA,KAAC,QAAK,GAAIH,EAAS,UAAU,0BAC1B,SAAA,CAAAF,GACCO,EAAAA,IAAC,QAAK,UAAU,0BACd,eAACG,EAAAA,aAAA,CAAa,MAAOxD,EAAO,KAAA,CAAO,CAAA,CACrC,EAED+C,GACCM,EAAAA,IAAC,OAAA,CAAK,UAAU,0BAA2B,WAAO,KAAA,CAAM,CAAA,CAAA,CAE5D,CAAA,CAAA,CAAA,EAGHR,SACE,MAAA,CAAI,UAAU,4BAA4B,KAAK,QAC7C,WAAK,SAAS,IAAI,CAACpC,EAAO8B,IACzBE,EAAWhC,EAAO8B,EAAQ,EAAGrC,EAAK,SAAS,MAAM,CAAA,CACnD,CACF,CAAA,CAAA,EAjFGF,EAAO,EAAA,CAqFlB,EAEA,OACEqD,EAAAA,IAAC,MAAA,CACC,UAAW,CAAC,mBAAoBjC,GAAa,EAAE,EAC5C,OAAO,OAAO,EACd,KAAK,GAAG,EACX,MAAAC,EACA,KAAK,OACL,aAAYN,EAEX,SAAAd,EAAM,IAAI,CAACS,EAAM6B,IAAUE,EAAW/B,EAAM6B,EAAQ,EAAGtC,EAAM,MAAM,CAAC,CAAA,CAAA,CAG3E"}
@@ -0,0 +1,53 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { LinkComponent } from './linkComponent';
3
+ import { WorkStatus } from './workStatus';
4
+ /**
5
+ * The state of a region, drawn as a dot before its label. `active` is work
6
+ * in progress: the ink dot pulses, as in `ServiceMap`.
7
+ */
8
+ export type RegionMapStatus = WorkStatus;
9
+ export interface RegionMapRegion {
10
+ id: string;
11
+ /** The region it lies in. A region whose `parentId` names no region is a top-level region. */
12
+ parentId?: string | null;
13
+ label: string;
14
+ /** The tile's accessible name. Default: `label`. */
15
+ ariaLabel?: string;
16
+ /** Default: no dot. */
17
+ status?: RegionMapStatus;
18
+ /** A number at the end of the tile's head, rolling to a new value. */
19
+ count?: number | string;
20
+ /**
21
+ * A state at the end of the tile's head, e.g. a `Chip`. Give a Chip in it
22
+ * `inverted` while the region is selected.
23
+ */
24
+ state?: ReactNode;
25
+ /**
26
+ * Makes the label a link to this destination. The tile stays the map's tab
27
+ * stop: the link is not a tab stop, and Enter on the tile follows it.
28
+ */
29
+ to?: string;
30
+ }
31
+ export interface RegionMapProps {
32
+ /** The regions in any order; each nests inside the region its `parentId` names. */
33
+ regions: RegionMapRegion[];
34
+ /** The map's accessible name. */
35
+ ariaLabel: string;
36
+ /** The selected region, drawn inverted. */
37
+ selectedId?: string;
38
+ onSelect?: (region: RegionMapRegion) => void;
39
+ /** Renders the labels of regions with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */
40
+ linkComponent?: LinkComponent;
41
+ className?: string;
42
+ style?: CSSProperties;
43
+ }
44
+ /**
45
+ * A tree of regions drawn as nested tiles that fill their container, like a
46
+ * territory map: each region holds the tiles of the regions inside it, and
47
+ * a region with more regions under it takes more room. Each tile carries a
48
+ * status dot, a label that may be a link, a count and a state slot; the
49
+ * selected tile is inverted. For assistive technology the map is a tree
50
+ * whose regions read in order, each named by its label and described by
51
+ * its count and state.
52
+ */
53
+ export declare function RegionMap({ regions, ariaLabel, selectedId, onSelect, linkComponent: Link, className, style, }: RegionMapProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,173 @@
1
+ import { jsx as g, jsxs as b } from "react/jsx-runtime";
2
+ import { useId as B, useRef as F, useMemo as E, useState as O } from "react";
3
+ /* empty css */
4
+ import { RollingValue as $ } from "./RollingValue.js";
5
+ import { StatusDot as q } from "./StatusDot.js";
6
+ import { DefaultLink as U } from "./linkComponent.js";
7
+ import { workStatusDot as z } from "./workStatus.js";
8
+ const H = 4;
9
+ function P(p) {
10
+ const s = /* @__PURE__ */ new Map();
11
+ p.forEach((r) => {
12
+ s.set(r.id, {
13
+ region: r,
14
+ parent: null,
15
+ children: [],
16
+ depth: 0,
17
+ leaves: 1
18
+ });
19
+ });
20
+ const n = [];
21
+ s.forEach((r) => {
22
+ const d = r.region.parentId, l = d ? s.get(d) : void 0;
23
+ let o = l;
24
+ for (; o !== void 0 && o !== r; )
25
+ o = o.parent ?? void 0;
26
+ l && o === void 0 ? (r.parent = l, l.children.push(r)) : n.push(r);
27
+ });
28
+ const m = (r, d) => (r.depth = d, r.leaves = r.children.length ? r.children.reduce((l, o) => l + m(o, d + 1), 0) : 1, r.leaves);
29
+ return n.forEach((r) => {
30
+ m(r, 0);
31
+ }), n;
32
+ }
33
+ function C(p, s = []) {
34
+ return p.forEach((n) => {
35
+ s.push(n), C(n.children, s);
36
+ }), s;
37
+ }
38
+ function Z({
39
+ regions: p,
40
+ ariaLabel: s,
41
+ selectedId: n,
42
+ onSelect: m,
43
+ linkComponent: r = U,
44
+ className: d,
45
+ style: l
46
+ }) {
47
+ const o = B(), k = F(/* @__PURE__ */ new Map()), u = E(() => P(p), [p]), c = E(() => C(u), [u]), [S, M] = O(void 0), N = (e) => e === void 0 ? -1 : c.findIndex((i) => i.region.id === e), y = N(S), T = c[y >= 0 ? y : Math.max(N(n), 0)]?.region.id, h = (e) => {
48
+ e && (M(e.region.id), k.current.get(e.region.id)?.focus());
49
+ }, j = (e, i) => {
50
+ if (e.target !== e.currentTarget)
51
+ return;
52
+ const f = c.indexOf(i);
53
+ switch (e.key) {
54
+ case "ArrowDown":
55
+ h(c[f + 1]);
56
+ break;
57
+ case "ArrowUp":
58
+ h(c[f - 1]);
59
+ break;
60
+ case "ArrowRight":
61
+ h(i.children[0]);
62
+ break;
63
+ case "ArrowLeft":
64
+ h(i.parent);
65
+ break;
66
+ case "Home":
67
+ h(c[0]);
68
+ break;
69
+ case "End":
70
+ h(c[c.length - 1]);
71
+ break;
72
+ case "Enter":
73
+ i.region.to !== void 0 ? e.currentTarget.querySelector(
74
+ ":scope > .aegis-region-map__head .aegis-region-map__label a"
75
+ )?.click() : m?.(i.region);
76
+ break;
77
+ case " ":
78
+ m?.(i.region);
79
+ break;
80
+ default:
81
+ return;
82
+ }
83
+ e.preventDefault();
84
+ }, A = (e, i) => {
85
+ !(e.target instanceof Element) || e.target.closest('[role="treeitem"]') !== e.currentTarget || (e.ctrlKey || e.metaKey || e.shiftKey) && e.target.closest(".aegis-region-map__label a") !== null || m?.(i.region);
86
+ }, I = (e, i, f) => {
87
+ const { region: a } = e, _ = a.id === n, v = e.children.length > 0, w = a.count !== void 0 && a.count !== "", x = a.state !== void 0 && a.state !== null, D = `${o}-${a.id}-facts`, K = Math.min(Math.ceil(Math.sqrt(e.leaves)), H), L = [
88
+ "aegis-region-map__tile",
89
+ `aegis-region-map__tile--depth-${String(Math.min(e.depth, 3))}`,
90
+ v ? "" : "aegis-region-map__tile--leaf",
91
+ _ ? "aegis-region-map__tile--selected" : ""
92
+ ].filter(Boolean).join(" ");
93
+ return /* @__PURE__ */ b(
94
+ "div",
95
+ {
96
+ ref: (t) => {
97
+ t ? k.current.set(a.id, t) : k.current.delete(a.id);
98
+ },
99
+ className: L,
100
+ style: {
101
+ "--aegis-region-map-weight": e.leaves,
102
+ "--aegis-region-map-columns": K
103
+ },
104
+ role: "treeitem",
105
+ "aria-label": a.ariaLabel ?? a.label,
106
+ "aria-describedby": w || x ? D : void 0,
107
+ "aria-level": e.depth + 1,
108
+ "aria-posinset": i,
109
+ "aria-setsize": f,
110
+ "aria-expanded": v ? !0 : void 0,
111
+ "aria-selected": _,
112
+ tabIndex: a.id === T ? 0 : -1,
113
+ onClick: (t) => {
114
+ A(t, e);
115
+ },
116
+ onKeyDown: (t) => {
117
+ j(t, e);
118
+ },
119
+ onFocus: (t) => {
120
+ t.target === t.currentTarget && M(a.id);
121
+ },
122
+ children: [
123
+ /* @__PURE__ */ b(
124
+ "div",
125
+ {
126
+ className: [
127
+ "aegis-region-map__head",
128
+ e.depth === 0 ? "aegis-region-map__head--top" : "",
129
+ _ ? "aegis-region-map__head--selected" : ""
130
+ ].filter(Boolean).join(" "),
131
+ children: [
132
+ /* @__PURE__ */ b("span", { className: "aegis-region-map__name", children: [
133
+ a.status !== void 0 && /* @__PURE__ */ g(q, { ...z(a.status, _) }),
134
+ /* @__PURE__ */ g("span", { className: "aegis-region-map__label", children: a.to === void 0 ? a.label : /* @__PURE__ */ g(
135
+ r,
136
+ {
137
+ to: a.to,
138
+ className: "aegis-region-map__link",
139
+ tabIndex: -1,
140
+ children: a.label
141
+ }
142
+ ) })
143
+ ] }),
144
+ (w || x) && /* @__PURE__ */ b("span", { id: D, className: "aegis-region-map__facts", children: [
145
+ w && /* @__PURE__ */ g("span", { className: "aegis-region-map__count", children: /* @__PURE__ */ g($, { value: a.count }) }),
146
+ x && /* @__PURE__ */ g("span", { className: "aegis-region-map__state", children: a.state })
147
+ ] })
148
+ ]
149
+ }
150
+ ),
151
+ v && /* @__PURE__ */ g("div", { className: "aegis-region-map__regions", role: "group", children: e.children.map(
152
+ (t, R) => I(t, R + 1, e.children.length)
153
+ ) })
154
+ ]
155
+ },
156
+ a.id
157
+ );
158
+ };
159
+ return /* @__PURE__ */ g(
160
+ "div",
161
+ {
162
+ className: ["aegis-region-map", d ?? ""].filter(Boolean).join(" "),
163
+ style: l,
164
+ role: "tree",
165
+ "aria-label": s,
166
+ children: u.map((e, i) => I(e, i + 1, u.length))
167
+ }
168
+ );
169
+ }
170
+ export {
171
+ Z as RegionMap
172
+ };
173
+ //# sourceMappingURL=RegionMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegionMap.js","sources":["../../../src/components/ui/RegionMap.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport './RegionMap.css';\nimport { RollingValue } from './RollingValue';\nimport { StatusDot } from './StatusDot';\nimport { DefaultLink, type LinkComponent } from './linkComponent';\nimport { type WorkStatus, workStatusDot } from './workStatus';\n\n/**\n * The state of a region, drawn as a dot before its label. `active` is work\n * in progress: the ink dot pulses, as in `ServiceMap`.\n */\nexport type RegionMapStatus = WorkStatus;\n\nexport interface RegionMapRegion {\n id: string;\n /** The region it lies in. A region whose `parentId` names no region is a top-level region. */\n parentId?: string | null;\n label: string;\n /** The tile's accessible name. Default: `label`. */\n ariaLabel?: string;\n /** Default: no dot. */\n status?: RegionMapStatus;\n /** A number at the end of the tile's head, rolling to a new value. */\n count?: number | string;\n /**\n * A state at the end of the tile's head, e.g. a `Chip`. Give a Chip in it\n * `inverted` while the region is selected.\n */\n state?: ReactNode;\n /**\n * Makes the label a link to this destination. The tile stays the map's tab\n * stop: the link is not a tab stop, and Enter on the tile follows it.\n */\n to?: string;\n}\n\nexport interface RegionMapProps {\n /** The regions in any order; each nests inside the region its `parentId` names. */\n regions: RegionMapRegion[];\n /** The map's accessible name. */\n ariaLabel: string;\n /** The selected region, drawn inverted. */\n selectedId?: string;\n onSelect?: (region: RegionMapRegion) => void;\n /** Renders the labels of regions with `to`. Defaults to an `<a href>`; routed apps pass their Link adapter. */\n linkComponent?: LinkComponent;\n className?: string;\n style?: CSSProperties;\n}\n\ninterface Node {\n region: RegionMapRegion;\n parent: Node | null;\n children: Node[];\n depth: number;\n leaves: number;\n}\n\nconst MAX_COLUMNS = 4;\n\nfunction buildForest(regions: RegionMapRegion[]): Node[] {\n const byId = new Map<string, Node>();\n regions.forEach((region) => {\n byId.set(region.id, {\n region,\n parent: null,\n children: [],\n depth: 0,\n leaves: 1,\n });\n });\n const roots: Node[] = [];\n byId.forEach((node) => {\n const pid = node.region.parentId;\n const parent = pid ? byId.get(pid) : undefined;\n // A parent that is the region itself, or lies inside it, would close a\n // cycle; the region becomes a top-level one instead.\n let ancestor = parent;\n while (ancestor !== undefined && ancestor !== node) {\n ancestor = ancestor.parent ?? undefined;\n }\n if (parent && ancestor === undefined) {\n node.parent = parent;\n parent.children.push(node);\n } else {\n roots.push(node);\n }\n });\n const place = (node: Node, depth: number): number => {\n node.depth = depth;\n node.leaves = node.children.length\n ? node.children.reduce((sum, child) => sum + place(child, depth + 1), 0)\n : 1;\n return node.leaves;\n };\n roots.forEach((root) => {\n place(root, 0);\n });\n return roots;\n}\n\nfunction preorder(nodes: Node[], out: Node[] = []): Node[] {\n nodes.forEach((node) => {\n out.push(node);\n preorder(node.children, out);\n });\n return out;\n}\n\n/**\n * A tree of regions drawn as nested tiles that fill their container, like a\n * territory map: each region holds the tiles of the regions inside it, and\n * a region with more regions under it takes more room. Each tile carries a\n * status dot, a label that may be a link, a count and a state slot; the\n * selected tile is inverted. For assistive technology the map is a tree\n * whose regions read in order, each named by its label and described by\n * its count and state.\n */\nexport function RegionMap({\n regions,\n ariaLabel,\n selectedId,\n onSelect,\n linkComponent: Link = DefaultLink,\n className,\n style,\n}: RegionMapProps) {\n const idPrefix = useId();\n const tiles = useRef(new Map<string, HTMLDivElement>());\n const roots = useMemo(() => buildForest(regions), [regions]);\n const order = useMemo(() => preorder(roots), [roots]);\n const [focusedId, setFocusedId] = useState<string | undefined>(undefined);\n\n const indexOf = (id: string | undefined): number =>\n id === undefined ? -1 : order.findIndex((n) => n.region.id === id);\n const focusedIndex = indexOf(focusedId);\n const tabStopId =\n order[focusedIndex >= 0 ? focusedIndex : Math.max(indexOf(selectedId), 0)]\n ?.region.id;\n\n const focusTile = (node: Node | null | undefined): void => {\n if (!node) {\n return;\n }\n setFocusedId(node.region.id);\n tiles.current.get(node.region.id)?.focus();\n };\n\n const handleKeyDown = (\n event: KeyboardEvent<HTMLDivElement>,\n node: Node,\n ): void => {\n if (event.target !== event.currentTarget) {\n return;\n }\n const index = order.indexOf(node);\n switch (event.key) {\n case 'ArrowDown':\n focusTile(order[index + 1]);\n break;\n case 'ArrowUp':\n focusTile(order[index - 1]);\n break;\n case 'ArrowRight':\n focusTile(node.children[0]);\n break;\n case 'ArrowLeft':\n focusTile(node.parent);\n break;\n case 'Home':\n focusTile(order[0]);\n break;\n case 'End':\n focusTile(order[order.length - 1]);\n break;\n // The link's click reaches the tile, which selects it too.\n case 'Enter':\n if (node.region.to !== undefined) {\n event.currentTarget\n .querySelector<HTMLElement>(\n ':scope > .aegis-region-map__head .aegis-region-map__label a',\n )\n ?.click();\n } else {\n onSelect?.(node.region);\n }\n break;\n case ' ':\n onSelect?.(node.region);\n break;\n default:\n return;\n }\n event.preventDefault();\n };\n\n const handleClick = (event: MouseEvent<HTMLDivElement>, node: Node): void => {\n // Only the innermost tile under the pointer takes the click.\n if (\n !(event.target instanceof Element) ||\n event.target.closest('[role=\"treeitem\"]') !== event.currentTarget\n ) {\n return;\n }\n // A modified click opens the label's link elsewhere and leaves this\n // page's selection alone.\n if (\n (event.ctrlKey || event.metaKey || event.shiftKey) &&\n event.target.closest('.aegis-region-map__label a') !== null\n ) {\n return;\n }\n onSelect?.(node.region);\n };\n\n const renderTile = (\n node: Node,\n position: number,\n siblings: number,\n ): ReactNode => {\n const { region } = node;\n const selected = region.id === selectedId;\n const hasChildren = node.children.length > 0;\n const hasCount = region.count !== undefined && region.count !== '';\n const hasState = region.state !== undefined && region.state !== null;\n const factsId = `${idPrefix}-${region.id}-facts`;\n const columns = Math.min(Math.ceil(Math.sqrt(node.leaves)), MAX_COLUMNS);\n const cls = [\n 'aegis-region-map__tile',\n `aegis-region-map__tile--depth-${String(Math.min(node.depth, 3))}`,\n hasChildren ? '' : 'aegis-region-map__tile--leaf',\n selected ? 'aegis-region-map__tile--selected' : '',\n ]\n .filter(Boolean)\n .join(' ');\n return (\n <div\n key={region.id}\n ref={(element) => {\n if (element) {\n tiles.current.set(region.id, element);\n } else {\n tiles.current.delete(region.id);\n }\n }}\n className={cls}\n style={\n {\n '--aegis-region-map-weight': node.leaves,\n '--aegis-region-map-columns': columns,\n } as CSSProperties\n }\n role=\"treeitem\"\n aria-label={region.ariaLabel ?? region.label}\n aria-describedby={hasCount || hasState ? factsId : undefined}\n aria-level={node.depth + 1}\n aria-posinset={position}\n aria-setsize={siblings}\n aria-expanded={hasChildren ? true : undefined}\n aria-selected={selected}\n tabIndex={region.id === tabStopId ? 0 : -1}\n onClick={(event) => {\n handleClick(event, node);\n }}\n onKeyDown={(event) => {\n handleKeyDown(event, node);\n }}\n onFocus={(event) => {\n if (event.target === event.currentTarget) {\n setFocusedId(region.id);\n }\n }}\n >\n <div\n className={[\n 'aegis-region-map__head',\n node.depth === 0 ? 'aegis-region-map__head--top' : '',\n selected ? 'aegis-region-map__head--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <span className=\"aegis-region-map__name\">\n {region.status !== undefined && (\n <StatusDot {...workStatusDot(region.status, selected)} />\n )}\n <span className=\"aegis-region-map__label\">\n {region.to === undefined ? (\n region.label\n ) : (\n <Link\n to={region.to}\n className=\"aegis-region-map__link\"\n tabIndex={-1}\n >\n {region.label}\n </Link>\n )}\n </span>\n </span>\n {(hasCount || hasState) && (\n <span id={factsId} className=\"aegis-region-map__facts\">\n {hasCount && (\n <span className=\"aegis-region-map__count\">\n <RollingValue value={region.count} />\n </span>\n )}\n {hasState && (\n <span className=\"aegis-region-map__state\">{region.state}</span>\n )}\n </span>\n )}\n </div>\n {hasChildren && (\n <div className=\"aegis-region-map__regions\" role=\"group\">\n {node.children.map((child, index) =>\n renderTile(child, index + 1, node.children.length),\n )}\n </div>\n )}\n </div>\n );\n };\n\n return (\n <div\n className={['aegis-region-map', className ?? '']\n .filter(Boolean)\n .join(' ')}\n style={style}\n role=\"tree\"\n aria-label={ariaLabel}\n >\n {roots.map((root, index) => renderTile(root, index + 1, roots.length))}\n </div>\n );\n}\n"],"names":["MAX_COLUMNS","buildForest","regions","byId","region","roots","node","pid","parent","ancestor","place","depth","sum","child","root","preorder","nodes","out","RegionMap","ariaLabel","selectedId","onSelect","Link","DefaultLink","className","style","idPrefix","useId","tiles","useRef","useMemo","order","focusedId","setFocusedId","useState","indexOf","id","n","focusedIndex","tabStopId","focusTile","handleKeyDown","event","index","handleClick","renderTile","position","siblings","selected","hasChildren","hasCount","hasState","factsId","columns","cls","jsxs","element","jsx","StatusDot","workStatusDot","RollingValue"],"mappings":";;;;;;;AAoEA,MAAMA,IAAc;AAEpB,SAASC,EAAYC,GAAoC;AACvD,QAAMC,wBAAW,IAAA;AACjB,EAAAD,EAAQ,QAAQ,CAACE,MAAW;AAC1B,IAAAD,EAAK,IAAIC,EAAO,IAAI;AAAA,MAClB,QAAAA;AAAA,MACA,QAAQ;AAAA,MACR,UAAU,CAAA;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,IAAA,CACT;AAAA,EACH,CAAC;AACD,QAAMC,IAAgB,CAAA;AACtB,EAAAF,EAAK,QAAQ,CAACG,MAAS;AACrB,UAAMC,IAAMD,EAAK,OAAO,UAClBE,IAASD,IAAMJ,EAAK,IAAII,CAAG,IAAI;AAGrC,QAAIE,IAAWD;AACf,WAAOC,MAAa,UAAaA,MAAaH;AAC5C,MAAAG,IAAWA,EAAS,UAAU;AAEhC,IAAID,KAAUC,MAAa,UACzBH,EAAK,SAASE,GACdA,EAAO,SAAS,KAAKF,CAAI,KAEzBD,EAAM,KAAKC,CAAI;AAAA,EAEnB,CAAC;AACD,QAAMI,IAAQ,CAACJ,GAAYK,OACzBL,EAAK,QAAQK,GACbL,EAAK,SAASA,EAAK,SAAS,SACxBA,EAAK,SAAS,OAAO,CAACM,GAAKC,MAAUD,IAAMF,EAAMG,GAAOF,IAAQ,CAAC,GAAG,CAAC,IACrE,GACGL,EAAK;AAEd,SAAAD,EAAM,QAAQ,CAACS,MAAS;AACtB,IAAAJ,EAAMI,GAAM,CAAC;AAAA,EACf,CAAC,GACMT;AACT;AAEA,SAASU,EAASC,GAAeC,IAAc,IAAY;AACzD,SAAAD,EAAM,QAAQ,CAACV,MAAS;AACtB,IAAAW,EAAI,KAAKX,CAAI,GACbS,EAAST,EAAK,UAAUW,CAAG;AAAA,EAC7B,CAAC,GACMA;AACT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AAqD;AAAA,oBAACnC;AAAA,oBAAA;AAAA,sBACC,IAAIlB,EAAO;AAAA,sBACX,WAAU;AAAA,sBACV,UAAU;AAAA,sBAET,UAAAA,EAAO;AAAA,oBAAA;AAAA,kBAAA,EACV,CAEJ;AAAA,gBAAA,GACF;AAAA,iBACE8C,KAAYC,MACZ,gBAAAI,EAAC,UAAK,IAAIH,GAAS,WAAU,2BAC1B,UAAA;AAAA,kBAAAF,KACC,gBAAAO,EAAC,UAAK,WAAU,2BACd,4BAACG,GAAA,EAAa,OAAOxD,EAAO,MAAA,CAAO,EAAA,CACrC;AAAA,kBAED+C,KACC,gBAAAM,EAAC,QAAA,EAAK,WAAU,2BAA2B,YAAO,MAAA,CAAM;AAAA,gBAAA,EAAA,CAE5D;AAAA,cAAA;AAAA,YAAA;AAAA,UAAA;AAAA,UAGHR,uBACE,OAAA,EAAI,WAAU,6BAA4B,MAAK,SAC7C,YAAK,SAAS;AAAA,YAAI,CAACpC,GAAO8B,MACzBE,EAAWhC,GAAO8B,IAAQ,GAAGrC,EAAK,SAAS,MAAM;AAAA,UAAA,EACnD,CACF;AAAA,QAAA;AAAA,MAAA;AAAA,MAjFGF,EAAO;AAAA,IAAA;AAAA,EAqFlB;AAEA,SACE,gBAAAqD;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW,CAAC,oBAAoBjC,KAAa,EAAE,EAC5C,OAAO,OAAO,EACd,KAAK,GAAG;AAAA,MACX,OAAAC;AAAA,MACA,MAAK;AAAA,MACL,cAAYN;AAAA,MAEX,UAAAd,EAAM,IAAI,CAACS,GAAM6B,MAAUE,EAAW/B,GAAM6B,IAAQ,GAAGtC,EAAM,MAAM,CAAC;AAAA,IAAA;AAAA,EAAA;AAG3E;"}
@@ -1 +1 @@
1
- {"version":3,"file":"RollingValue.cjs","sources":["../../../src/components/ui/RollingValue.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\n\nimport './RollingValue.css';\n\ninterface RollingValueProps {\n value: ReactNode;\n}\n\n/**\n * Renders a number or numeric string whose digits roll to their new value\n * when it changes, right column first; the first render does not move.\n * Columns are keyed from the right so they stay put as the value grows.\n * The value itself sits in one visually hidden span, so screen readers,\n * copy and text queries read it whole; every visible face is generated\n * content inside an aria-hidden span. Any other node renders as is.\n */\nexport function RollingValue({ value }: RollingValueProps): ReactNode {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return value;\n }\n const text = String(value);\n if (!/\\d/.test(text)) {\n return text;\n }\n const chars = [...text];\n return (\n <span className=\"aegis-rolling-value\">\n <span className=\"aegis-rolling-value__text\">{text}</span>\n <span aria-hidden=\"true\">\n {chars.map((char, index) => {\n const column = chars.length - 1 - index;\n const digit = '0123456789'.indexOf(char);\n if (digit < 0) {\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__char\"\n data-char={char}\n />\n );\n }\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__digit\"\n data-char={char}\n style={\n {\n '--aegis-roll-column': column,\n '--aegis-roll-digit': digit,\n } as CSSProperties\n }\n />\n );\n })}\n </span>\n </span>\n );\n}\n"],"names":["RollingValue","value","text","chars","jsxs","jsx","char","index","column","digit"],"mappings":"uJAgBO,SAASA,EAAa,CAAE,MAAAC,GAAuC,CACpE,GAAI,OAAOA,GAAU,UAAY,OAAOA,GAAU,SAChD,OAAOA,EAET,MAAMC,EAAO,OAAOD,CAAK,EACzB,GAAI,CAAC,KAAK,KAAKC,CAAI,EACjB,OAAOA,EAET,MAAMC,EAAQ,CAAC,GAAGD,CAAI,EACtB,OACEE,EAAAA,KAAC,OAAA,CAAK,UAAU,sBACd,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAK,UAAU,4BAA6B,SAAAH,EAAK,EAClDG,MAAC,QAAK,cAAY,OACf,WAAM,IAAI,CAACC,EAAMC,IAAU,CAC1B,MAAMC,EAASL,EAAM,OAAS,EAAII,EAC5BE,EAAQ,aAAa,QAAQH,CAAI,EACvC,OAAIG,EAAQ,EAERJ,EAAAA,IAAC,OAAA,CAEC,UAAU,4BACV,YAAWC,CAAA,EAFNE,CAAA,EAOTH,EAAAA,IAAC,OAAA,CAEC,UAAU,6BACV,YAAWC,EACX,MACE,CACE,sBAAuBE,EACvB,qBAAsBC,CAAA,CACxB,EAPGD,CAAA,CAWX,CAAC,CAAA,CACH,CAAA,EACF,CAEJ"}
1
+ {"version":3,"file":"RollingValue.cjs","sources":["../../../src/components/ui/RollingValue.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\n\nimport './RollingValue.css';\n\nexport interface RollingValueProps {\n value: ReactNode;\n}\n\n/**\n * Renders a number or numeric string whose digits roll to their new value\n * when it changes, right column first; the first render does not move.\n * Columns are keyed from the right so they stay put as the value grows.\n * The value itself sits in one visually hidden span, so screen readers,\n * copy and text queries read it whole; every visible face is generated\n * content inside an aria-hidden span. Any other node renders as is.\n */\nexport function RollingValue({ value }: RollingValueProps): ReactNode {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return value;\n }\n const text = String(value);\n if (!/\\d/.test(text)) {\n return text;\n }\n const chars = [...text];\n return (\n <span className=\"aegis-rolling-value\">\n <span className=\"aegis-rolling-value__text\">{text}</span>\n <span aria-hidden=\"true\">\n {chars.map((char, index) => {\n const column = chars.length - 1 - index;\n const digit = '0123456789'.indexOf(char);\n if (digit < 0) {\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__char\"\n data-char={char}\n />\n );\n }\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__digit\"\n data-char={char}\n style={\n {\n '--aegis-roll-column': column,\n '--aegis-roll-digit': digit,\n } as CSSProperties\n }\n />\n );\n })}\n </span>\n </span>\n );\n}\n"],"names":["RollingValue","value","text","chars","jsxs","jsx","char","index","column","digit"],"mappings":"uJAgBO,SAASA,EAAa,CAAE,MAAAC,GAAuC,CACpE,GAAI,OAAOA,GAAU,UAAY,OAAOA,GAAU,SAChD,OAAOA,EAET,MAAMC,EAAO,OAAOD,CAAK,EACzB,GAAI,CAAC,KAAK,KAAKC,CAAI,EACjB,OAAOA,EAET,MAAMC,EAAQ,CAAC,GAAGD,CAAI,EACtB,OACEE,EAAAA,KAAC,OAAA,CAAK,UAAU,sBACd,SAAA,CAAAC,EAAAA,IAAC,OAAA,CAAK,UAAU,4BAA6B,SAAAH,EAAK,EAClDG,MAAC,QAAK,cAAY,OACf,WAAM,IAAI,CAACC,EAAMC,IAAU,CAC1B,MAAMC,EAASL,EAAM,OAAS,EAAII,EAC5BE,EAAQ,aAAa,QAAQH,CAAI,EACvC,OAAIG,EAAQ,EAERJ,EAAAA,IAAC,OAAA,CAEC,UAAU,4BACV,YAAWC,CAAA,EAFNE,CAAA,EAOTH,EAAAA,IAAC,OAAA,CAEC,UAAU,6BACV,YAAWC,EACX,MACE,CACE,sBAAuBE,EACvB,qBAAsBC,CAAA,CACxB,EAPGD,CAAA,CAWX,CAAC,CAAA,CACH,CAAA,EACF,CAEJ"}
@@ -1,5 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
- interface RollingValueProps {
2
+ export interface RollingValueProps {
3
3
  value: ReactNode;
4
4
  }
5
5
  /**
@@ -11,4 +11,3 @@ interface RollingValueProps {
11
11
  * content inside an aria-hidden span. Any other node renders as is.
12
12
  */
13
13
  export declare function RollingValue({ value }: RollingValueProps): ReactNode;
14
- export {};
@@ -1 +1 @@
1
- {"version":3,"file":"RollingValue.js","sources":["../../../src/components/ui/RollingValue.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\n\nimport './RollingValue.css';\n\ninterface RollingValueProps {\n value: ReactNode;\n}\n\n/**\n * Renders a number or numeric string whose digits roll to their new value\n * when it changes, right column first; the first render does not move.\n * Columns are keyed from the right so they stay put as the value grows.\n * The value itself sits in one visually hidden span, so screen readers,\n * copy and text queries read it whole; every visible face is generated\n * content inside an aria-hidden span. Any other node renders as is.\n */\nexport function RollingValue({ value }: RollingValueProps): ReactNode {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return value;\n }\n const text = String(value);\n if (!/\\d/.test(text)) {\n return text;\n }\n const chars = [...text];\n return (\n <span className=\"aegis-rolling-value\">\n <span className=\"aegis-rolling-value__text\">{text}</span>\n <span aria-hidden=\"true\">\n {chars.map((char, index) => {\n const column = chars.length - 1 - index;\n const digit = '0123456789'.indexOf(char);\n if (digit < 0) {\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__char\"\n data-char={char}\n />\n );\n }\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__digit\"\n data-char={char}\n style={\n {\n '--aegis-roll-column': column,\n '--aegis-roll-digit': digit,\n } as CSSProperties\n }\n />\n );\n })}\n </span>\n </span>\n );\n}\n"],"names":["RollingValue","value","text","chars","jsxs","jsx","char","index","column","digit"],"mappings":";;AAgBO,SAASA,EAAa,EAAE,OAAAC,KAAuC;AACpE,MAAI,OAAOA,KAAU,YAAY,OAAOA,KAAU;AAChD,WAAOA;AAET,QAAMC,IAAO,OAAOD,CAAK;AACzB,MAAI,CAAC,KAAK,KAAKC,CAAI;AACjB,WAAOA;AAET,QAAMC,IAAQ,CAAC,GAAGD,CAAI;AACtB,SACE,gBAAAE,EAAC,QAAA,EAAK,WAAU,uBACd,UAAA;AAAA,IAAA,gBAAAC,EAAC,QAAA,EAAK,WAAU,6BAA6B,UAAAH,GAAK;AAAA,IAClD,gBAAAG,EAAC,UAAK,eAAY,QACf,YAAM,IAAI,CAACC,GAAMC,MAAU;AAC1B,YAAMC,IAASL,EAAM,SAAS,IAAII,GAC5BE,IAAQ,aAAa,QAAQH,CAAI;AACvC,aAAIG,IAAQ,IAER,gBAAAJ;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,aAAWC;AAAA,QAAA;AAAA,QAFNE;AAAA,MAAA,IAOT,gBAAAH;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,aAAWC;AAAA,UACX,OACE;AAAA,YACE,uBAAuBE;AAAA,YACvB,sBAAsBC;AAAA,UAAA;AAAA,QACxB;AAAA,QAPGD;AAAA,MAAA;AAAA,IAWX,CAAC,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"RollingValue.js","sources":["../../../src/components/ui/RollingValue.tsx"],"sourcesContent":["import type { CSSProperties, ReactNode } from 'react';\n\nimport './RollingValue.css';\n\nexport interface RollingValueProps {\n value: ReactNode;\n}\n\n/**\n * Renders a number or numeric string whose digits roll to their new value\n * when it changes, right column first; the first render does not move.\n * Columns are keyed from the right so they stay put as the value grows.\n * The value itself sits in one visually hidden span, so screen readers,\n * copy and text queries read it whole; every visible face is generated\n * content inside an aria-hidden span. Any other node renders as is.\n */\nexport function RollingValue({ value }: RollingValueProps): ReactNode {\n if (typeof value !== 'string' && typeof value !== 'number') {\n return value;\n }\n const text = String(value);\n if (!/\\d/.test(text)) {\n return text;\n }\n const chars = [...text];\n return (\n <span className=\"aegis-rolling-value\">\n <span className=\"aegis-rolling-value__text\">{text}</span>\n <span aria-hidden=\"true\">\n {chars.map((char, index) => {\n const column = chars.length - 1 - index;\n const digit = '0123456789'.indexOf(char);\n if (digit < 0) {\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__char\"\n data-char={char}\n />\n );\n }\n return (\n <span\n key={column}\n className=\"aegis-rolling-value__digit\"\n data-char={char}\n style={\n {\n '--aegis-roll-column': column,\n '--aegis-roll-digit': digit,\n } as CSSProperties\n }\n />\n );\n })}\n </span>\n </span>\n );\n}\n"],"names":["RollingValue","value","text","chars","jsxs","jsx","char","index","column","digit"],"mappings":";;AAgBO,SAASA,EAAa,EAAE,OAAAC,KAAuC;AACpE,MAAI,OAAOA,KAAU,YAAY,OAAOA,KAAU;AAChD,WAAOA;AAET,QAAMC,IAAO,OAAOD,CAAK;AACzB,MAAI,CAAC,KAAK,KAAKC,CAAI;AACjB,WAAOA;AAET,QAAMC,IAAQ,CAAC,GAAGD,CAAI;AACtB,SACE,gBAAAE,EAAC,QAAA,EAAK,WAAU,uBACd,UAAA;AAAA,IAAA,gBAAAC,EAAC,QAAA,EAAK,WAAU,6BAA6B,UAAAH,GAAK;AAAA,IAClD,gBAAAG,EAAC,UAAK,eAAY,QACf,YAAM,IAAI,CAACC,GAAMC,MAAU;AAC1B,YAAMC,IAASL,EAAM,SAAS,IAAII,GAC5BE,IAAQ,aAAa,QAAQH,CAAI;AACvC,aAAIG,IAAQ,IAER,gBAAAJ;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,aAAWC;AAAA,QAAA;AAAA,QAFNE;AAAA,MAAA,IAOT,gBAAAH;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UACV,aAAWC;AAAA,UACX,OACE;AAAA,YACE,uBAAuBE;AAAA,YACvB,sBAAsBC;AAAA,UAAA;AAAA,QACxB;AAAA,QAPGD;AAAA,MAAA;AAAA,IAWX,CAAC,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),h=require("react"),Y=require("@dagrejs/dagre"),g=require("@xyflow/react"),Z=require("../../hooks/useIsomorphicLayoutEffect.cjs"),ne=require("../../hooks/useMediaQuery.cjs");;/* empty css */const ae=require("./StatusDot.cjs"),re=require("./selectedRowDetail.cjs"),ce=require("../../locale/useStrings.cjs"),U=180,W=64,le=320,Q=28,de=64,ue={"--aegis-service-map-node-w":`${String(U)}px`,"--aegis-service-map-node-h":`${String(W)}px`,"--aegis-service-map-node-max-w":`${String(le)}px`,"--aegis-service-map-group-label-h":`${String(Q)}px`},ge={width:U,height:W};function pe(t,o,r,n){const a=t.map(s=>s.id),p=new Set(a);return{direction:n,ids:a,links:o.filter(s=>p.has(s.source)&&p.has(s.target)).map(s=>[s.source,s.target]),groups:r}}function me(t,o){const r=new Set(t),n=new Set,a=o.map(s=>{const l=[...new Set(s.nodeIds)].filter(i=>r.has(i)&&!n.has(i));return l.forEach(i=>n.add(i)),{group:s,ids:l}}),p=t.filter(s=>!n.has(s));return[...a,{ids:p}].filter(s=>s.ids.length>0)}function fe(t,o,r,n){const a=new Y.graphlib.Graph;a.setDefaultEdgeLabel(()=>({})),a.setGraph({rankdir:r,nodesep:40,ranksep:80,marginx:16,marginy:16});for(const i of t)a.setNode(i,{...n(i)});for(const[i,e]of o)a.hasNode(i)&&a.hasNode(e)&&a.setEdge(i,e);Y.layout(a);const p=new Map(t.map(i=>{const{x:e=0,y:m=0}=a.node(i),f=n(i);return[i,{x:e-f.width/2,y:m-f.height/2}]})),{width:s=0,height:l=0}=a.graph();return{positions:p,width:s,height:l}}function he(t,o,r){const n=e=>`${r}-group-${String(t.groups.indexOf(e))}`,a=t.direction==="LR",p=me(t.ids,t.groups).map(e=>{const m=fe(e.ids,t.links,t.direction,v=>o.get(v)??ge),f=e.group===void 0?0:Q;return{...e,...m,labelHeight:f,boxHeight:m.height+f}}),s=Math.max(0,...p.map(e=>a?e.boxHeight:e.width));let l=0;const i=p.map(e=>{const m=a?{x:l,y:(s-e.boxHeight)/2}:{x:(s-e.width)/2,y:l};return l+=(a?e.width:e.boxHeight)+de,{...e,origin:m}});return{groups:i.flatMap(e=>e.group===void 0?[]:[{id:`group:${e.group.id}`,type:"serviceGroup",position:e.origin,width:e.width,height:e.boxHeight,data:{label:e.group.label,labelId:n(e.group)},domAttributes:{"aria-roledescription":void 0,"aria-describedby":void 0},zIndex:-1,style:{pointerEvents:"none"},draggable:!1,connectable:!1,selectable:!1,focusable:!1}]),positions:new Map(i.flatMap(e=>[...e.positions].map(([m,f])=>[m,{x:e.origin.x+f.x,y:e.origin.y+e.labelHeight+f.y}]))),groupLabels:new Map(i.flatMap(e=>{const{group:m}=e;return m===void 0?[]:e.ids.map(f=>[f,n(m)])}))}}function ve({data:t}){return d.jsx("div",{className:"aegis-service-map__group",children:d.jsx("span",{id:t.labelId,className:"aegis-service-map__group-label",children:t.label})})}const be={ok:"ink",active:"ink",warn:"caution",error:"warning",muted:"muted"};function _e({data:t}){const{node:o,selected:r}=t,n=o.status??"ok",a=be[n];return d.jsxs("div",{className:["aegis-service-map__node",`aegis-service-map__node--${n}`,r?"aegis-service-map__node--selected":""].filter(Boolean).join(" "),children:[d.jsx(g.Handle,{type:"target",position:g.Position.Left,className:"aegis-service-map__handle"}),d.jsxs("div",{className:"aegis-service-map__node-body",children:[d.jsxs("div",{className:"aegis-service-map__node-label",children:[d.jsx(ae.StatusDot,{pulse:n==="active",tone:r&&a==="ink"?"inverted":a}),d.jsx("span",{className:"aegis-service-map__node-label-text",children:o.label})]}),o.sublabel!==void 0&&d.jsx("div",{className:"aegis-service-map__node-sublabel",children:o.sublabel})]}),o.badge!==void 0&&o.badge!==""&&d.jsx("span",{className:`aegis-service-map__node-badge aegis-service-map__node-badge--${n}`,children:o.badge}),d.jsx(g.Handle,{type:"source",position:g.Position.Right,className:"aegis-service-map__handle"})]})}function xe(t){const{sourceX:o,sourceY:r,targetX:n,targetY:a,label:p,markerEnd:s,style:l}=t,i=h.useId(),e=(o+n)/2,m=`M${o},${r} C${e},${r} ${e},${a} ${n},${a}`;return d.jsxs(d.Fragment,{children:[d.jsx("path",{d:m,className:"aegis-service-map__edge-focus",fill:"none"}),d.jsx("path",{id:i,d:m,className:"aegis-service-map__edge-path",markerEnd:s,style:l,fill:"none"}),p!==void 0&&p!==""&&d.jsx("text",{className:"aegis-service-map__edge-label",children:d.jsx("textPath",{href:`#${i}`,startOffset:"50%",textAnchor:"middle",children:p})})]})}const we={service:_e,serviceGroup:ve},ye={service:xe},Se="(max-width: 768px)",j=24,V=.1,B=1,X=11/13,q=15,J=28,K=200,C=t=>`${t}px`;function Me(t,o){return[...new Set([t,...o.filter(([r])=>r===t).map(([,r])=>r),...o.filter(([,r])=>r===t).map(([r])=>r)])]}function Ne(t){return t.type==="serviceGroup"?"aegis-service-map__minimap-group":""}function Ee(t,o,r,n,a,p){const{fitView:s,getNodes:l,getNodesBounds:i,setViewport:e}=g.useReactFlow(),m=g.useStoreApi(),f=g.useStore(x=>x.width>0&&x.height>0),v=h.useMemo(()=>n!==void 0&&t.ids.includes(n)?{id:n,near:Me(n,t.links)}:void 0,[n,t]),[M,P]=h.useState();return h.useEffect(()=>{if(f&&r){const x=()=>{P(v?.id??null)},w={top:C(j),bottom:C(j),left:C(q+J+j),right:C(a?q+K+j:j)},{width:N,height:S}=m.getState();if(v===void 0){const O=l(),E=i(O),L=g.getViewportForBounds(E,N,S,V,1,w);if(p&&L.zoom<X){const _=X,T=t.direction==="LR",H=y=>T?y.position.x:y.position.y,A=O.filter(y=>y.type==="service").reduce((y,I)=>H(I)<H(y)?I:y),{width:F=U,height:z=W}=A.measured??{};e(T?{x:q+J+j-E.x*_,y:S/2-(A.position.y+z/2)*_,zoom:_}:{x:N/2-(A.position.x+F/2)*_,y:j-E.y*_,zoom:_}).then(x)}else s({maxZoom:1,padding:w}).then(x)}else{const O=g.getViewportForBounds(i(v.near),N,S,V,B,w).zoom>=B;s({nodes:(O?v.near:[v.id]).map(E=>({id:E})),minZoom:B,maxZoom:B,padding:w}).then(x)}}},[f,r,o,v,a,p,t.direction,m,s,l,i,e]),M===(v?.id??null)}function Re({nodeId:t,selection:o}){const r=g.useStore(e=>e.transform),n=g.useStore(e=>e.domNode),a=g.useInternalNode(t);Z.useIsomorphicLayoutEffect(()=>()=>{o.placeRow(null)},[o]),Z.useIsomorphicLayoutEffect(()=>{const e=n?.querySelector(`.react-flow__node[data-id="${CSS.escape(t)}"]`);e instanceof HTMLElement&&o.placeRow(e)},[o,n,t,r]);const p=a?.measured.height;if(o.inline===null||a===void 0||p===void 0)return null;const[,s,l]=r,i=(a.internals.positionAbsolute.y+p)*l+s;return d.jsx("div",{className:"aegis-service-map__detail",style:{marginTop:Math.max(i,0)},children:o.inline})}function je(){const{getViewport:t,setViewport:o}=g.useReactFlow();return h.useCallback(r=>{const n=r.target;if(!(n instanceof Element)||!n.matches(".react-flow__node:focus-visible, .react-flow__edge:focus-visible"))return;const{scrollLeft:a,scrollTop:p}=r.currentTarget,s=r.currentTarget.getBoundingClientRect(),l=n.getBoundingClientRect(),i=l.left-s.left+a,e=l.top-s.top+p;if(i>=0&&e>=0&&i+l.width<=s.width&&e+l.height<=s.height)return;const{x:m,y:f,zoom:v}=t();o({x:m+s.width/2-(i+l.width/2),y:f+s.height/2-(e+l.height/2),zoom:v})},[t,o])}function Oe({nodes:t,edges:o,groups:r=[],direction:n="LR",height:a,fillViewport:p=!1,onNodeClick:s,onEdgeClick:l,selectedNodeId:i,focusNodeId:e,minimap:m=e===void 0,ariaLabel:f,className:v}){const M=ce.useStrings(),P=h.useId(),x=`aegis-service-map${P.replace(/:/g,"-")}`,w=s!==void 0,N=l!==void 0,[S,O]=h.useState(()=>new Map),E=h.useMemo(()=>JSON.stringify(pe(t,o,r,n)),[t,o,r,n]),L=h.useMemo(()=>JSON.parse(E),[E]),_=h.useMemo(()=>he(L,S,P),[L,S,P]),T=n==="LR",H=h.useMemo(()=>[..._.groups,...t.map(u=>{const c=[_.groupLabels.get(u.id),w?`react-flow__node-desc-${x}`:void 0].filter(Boolean).join(" ");return{id:u.id,type:"service",position:_.positions.get(u.id)??{x:0,y:0},measured:S.get(u.id),ariaLabel:u.label,ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapNodeRole,"aria-current":i===u.id?!0:void 0,"aria-describedby":c===""?void 0:c},data:{node:u,selected:i===u.id},sourcePosition:T?g.Position.Right:g.Position.Bottom,targetPosition:T?g.Position.Left:g.Position.Top,draggable:!1,connectable:!1,selectable:w,focusable:w}})],[_,t,S,i,T,w,x,M]),A=h.useMemo(()=>{const u=new Map(t.map(c=>[c.id,c.label]));return o.map(c=>({id:c.id,source:c.source,target:c.target,ariaLabel:M.serviceMapEdgeName(u.get(c.source)??c.source,u.get(c.target)??c.target),ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapEdgeRole},type:"service",data:{edge:c},label:c.label,selectable:N,focusable:N,className:`aegis-service-map__edge aegis-service-map__edge--${c.status??"ok"}`}))},[t,o,N,M]),{getNode:F}=g.useReactFlow(),z=h.useCallback(u=>{const c=u.flatMap(b=>b.type==="dimensions"&&b.dimensions!==void 0&&F(b.id)?.type==="service"?[[b.id,b.dimensions]]:[]);O(b=>c.every(([R,D])=>b.get(R)?.width===D.width&&b.get(R)?.height===D.height)?b:new Map([...b,...c]))},[F]),y=ne.useMediaQuery(Se),I=m&&!y,$=h.useContext(re.SelectedRowDetailContext),G=Ee(L,_,t.every(u=>S.has(u.id)),e,I,y),k=i!==void 0&&L.ids.includes(i)?i:void 0;Z.useIsomorphicLayoutEffect(()=>{if(!($===null||k===void 0||G))return $.awaitRow(),()=>{$.placeRow(null)}},[$,k,G]);const ee=je(),te=h.useCallback((u,c)=>{c.type==="service"&&s?.(c.data.node)},[s]),se=h.useCallback((u,c)=>{c.data&&l?.(c.data.edge)},[l]),oe=h.useCallback(u=>{if(u.key!=="Enter"&&u.key!==" "||u.repeat)return;const c=u.target;if(!(c instanceof Element))return;const b=c.getAttribute("data-id");if(c.classList.contains("react-flow__node")){const R=t.find(D=>D.id===b);R&&s&&(u.preventDefault(),s(R))}else if(c.classList.contains("react-flow__edge")){const R=o.find(D=>D.id===b);R&&l&&(u.preventDefault(),l(R))}},[t,o,s,l]),ie={...ue,height:a===void 0?void 0:`${String(a)}px`};return d.jsxs("div",{className:["aegis-service-map",p?"aegis-service-map--fill-viewport":"",v].filter(Boolean).join(" "),style:ie,children:[d.jsx("div",{className:"aegis-service-map__pane",children:d.jsxs(g.ReactFlow,{id:x,"aria-label":f,nodes:H,edges:A,nodeTypes:we,edgeTypes:ye,minZoom:V,nodesDraggable:!1,nodesConnectable:!1,autoPanOnNodeFocus:!1,panOnDrag:!0,zoomOnScroll:!0,proOptions:{hideAttribution:!0},ariaLabelConfig:M.serviceMapAriaLabels,onNodesChange:z,onNodeClick:w?te:void 0,onEdgeClick:N?se:void 0,onKeyDown:oe,onFocus:ee,children:[d.jsx(g.Background,{variant:g.BackgroundVariant.Dots,gap:16,size:1}),d.jsx(g.Controls,{showInteractive:!1,position:"top-left"}),I&&d.jsx(g.MiniMap,{pannable:!0,zoomable:!0,position:"bottom-right",style:{width:K},nodeClassName:Ne})]})}),$!==null&&G&&k!==void 0&&d.jsx(Re,{nodeId:k,selection:$})]})}function Le(t){return d.jsx(g.ReactFlowProvider,{children:d.jsx(Oe,{...t})})}exports.ServiceMap=Le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),f=require("react"),X=require("@dagrejs/dagre"),m=require("@xyflow/react"),V=require("../../hooks/useIsomorphicLayoutEffect.cjs"),re=require("../../hooks/useMediaQuery.cjs");;/* empty css */const ce=require("./StatusDot.cjs"),le=require("./selectedRowDetail.cjs"),de=require("./workStatus.cjs"),ue=require("../../locale/useStrings.cjs"),W=180,Y=64,ge=320,K=28,pe=64,me={"--aegis-service-map-node-w":`${String(W)}px`,"--aegis-service-map-node-h":`${String(Y)}px`,"--aegis-service-map-node-max-w":`${String(ge)}px`,"--aegis-service-map-group-label-h":`${String(K)}px`},fe={width:W,height:Y};function he(e,n,o,a){const r=e.map(s=>s.id),g=new Set(r);return{direction:a,ids:r,links:n.filter(s=>g.has(s.source)&&g.has(s.target)).map(s=>[s.source,s.target]),groups:o}}function ve(e,n){const o=new Set(e),a=new Set,r=n.map(s=>{const l=[...new Set(s.nodeIds)].filter(i=>o.has(i)&&!a.has(i));return l.forEach(i=>a.add(i)),{group:s,ids:l}}),g=e.filter(s=>!a.has(s));return[...r,{ids:g}].filter(s=>s.ids.length>0)}function be(e,n,o,a){const r=new X.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:o,nodesep:40,ranksep:80,marginx:16,marginy:16});for(const i of e)r.setNode(i,{...a(i)});for(const[i,t]of n)r.hasNode(i)&&r.hasNode(t)&&r.setEdge(i,t);X.layout(r);const g=new Map(e.map(i=>{const{x:t=0,y:d=0}=r.node(i),h=a(i);return[i,{x:t-h.width/2,y:d-h.height/2}]})),{width:s=0,height:l=0}=r.graph();return{positions:g,width:s,height:l}}function _e(e,n,o){const a=t=>`${o}-group-${String(e.groups.indexOf(t))}`,r=e.direction==="LR",g=ve(e.ids,e.groups).map(t=>{const d=be(t.ids,e.links,e.direction,v=>n.get(v)??fe),h=t.group===void 0?0:K;return{...t,...d,labelHeight:h,boxHeight:d.height+h}}),s=Math.max(0,...g.map(t=>r?t.boxHeight:t.width));let l=0;const i=g.map(t=>{const d=r?{x:l,y:(s-t.boxHeight)/2}:{x:(s-t.width)/2,y:l};return l+=(r?t.width:t.boxHeight)+pe,{...t,origin:d}});return{groups:i.flatMap(t=>t.group===void 0?[]:[{id:`group:${t.group.id}`,type:"serviceGroup",position:t.origin,width:t.width,height:t.boxHeight,data:{label:t.group.label,labelId:a(t.group)},domAttributes:{"aria-roledescription":void 0,"aria-describedby":void 0},zIndex:-1,style:{pointerEvents:"none"},draggable:!1,connectable:!1,selectable:!1,focusable:!1}]),positions:new Map(i.flatMap(t=>[...t.positions].map(([d,h])=>[d,{x:t.origin.x+h.x,y:t.origin.y+t.labelHeight+h.y}]))),groupLabels:new Map(i.flatMap(t=>{const{group:d}=t;return d===void 0?[]:t.ids.map(h=>[h,a(d)])}))}}function xe({data:e}){return u.jsx("div",{className:"aegis-service-map__group",children:u.jsx("span",{id:e.labelId,className:"aegis-service-map__group-label",children:e.label})})}function we({data:e}){const{node:n,selected:o}=e,a=n.status??"ok";return u.jsxs("div",{className:["aegis-service-map__node",`aegis-service-map__node--${a}`,o?"aegis-service-map__node--selected":""].filter(Boolean).join(" "),children:[u.jsx(m.Handle,{type:"target",position:m.Position.Left,className:"aegis-service-map__handle"}),u.jsxs("div",{className:"aegis-service-map__node-body",children:[u.jsxs("div",{className:"aegis-service-map__node-label",children:[u.jsx(ce.StatusDot,{...de.workStatusDot(a,o)}),u.jsx("span",{className:"aegis-service-map__node-label-text",children:n.label})]}),n.sublabel!==void 0&&u.jsx("div",{className:"aegis-service-map__node-sublabel",children:n.sublabel})]}),n.badge!==void 0&&n.badge!==""&&u.jsx("span",{className:`aegis-service-map__node-badge aegis-service-map__node-badge--${a}`,children:n.badge}),u.jsx(m.Handle,{type:"source",position:m.Position.Right,className:"aegis-service-map__handle"})]})}function ye(e){const{sourceX:n,sourceY:o,targetX:a,targetY:r,label:g,markerEnd:s,style:l}=e,i=f.useId(),t=(n+a)/2,d=`M${n},${o} C${t},${o} ${t},${r} ${a},${r}`;return u.jsxs(u.Fragment,{children:[u.jsx("path",{d,className:"aegis-service-map__edge-focus",fill:"none"}),u.jsx("path",{id:i,d,className:"aegis-service-map__edge-path",markerEnd:s,style:l,fill:"none"}),g!==void 0&&g!==""&&u.jsx("text",{className:"aegis-service-map__edge-label",children:u.jsx("textPath",{href:`#${i}`,startOffset:"50%",textAnchor:"middle",children:g})})]})}const Se={service:we,serviceGroup:xe},Me={service:ye},Ne="(max-width: 768px)",j=24,U=.1,z=1,J=11/13,Z=15,Q=28,ee=200,G=e=>`${e}px`;function Ee(e,n){return[...new Set([e,...n.filter(([o])=>o===e).map(([,o])=>o),...n.filter(([,o])=>o===e).map(([o])=>o)])]}function Re(e){return e.type==="serviceGroup"?"aegis-service-map__minimap-group":""}function je(e,n,o,a,r,g){const{fitView:s,getNodes:l,getNodesBounds:i,setViewport:t}=m.useReactFlow(),d=m.useStoreApi(),h=m.useStore(x=>x.width>0&&x.height>0),v=f.useMemo(()=>a!==void 0&&e.ids.includes(a)?{id:a,near:Ee(a,e.links)}:void 0,[a,e]),[M,I]=f.useState();return f.useEffect(()=>{if(h&&o){const x=()=>{I(v?.id??null)},w={top:G(j),bottom:G(j),left:G(Z+Q+j),right:G(r?Z+ee+j:j)},{width:N,height:S}=d.getState();if(v===void 0){const L=l(),E=i(L),O=m.getViewportForBounds(E,N,S,U,1,w);if(g&&O.zoom<J){const _=J,D=e.direction==="LR",H=y=>D?y.position.x:y.position.y,P=L.filter(y=>y.type==="service").reduce((y,A)=>H(A)<H(y)?A:y),{width:F=W,height:k=Y}=P.measured??{};t(D?{x:Z+Q+j-E.x*_,y:S/2-(P.position.y+k/2)*_,zoom:_}:{x:N/2-(P.position.x+F/2)*_,y:j-E.y*_,zoom:_}).then(x)}else s({maxZoom:1,padding:w}).then(x)}else{const L=m.getViewportForBounds(i(v.near),N,S,U,z,w).zoom>=z;s({nodes:(L?v.near:[v.id]).map(E=>({id:E})),minZoom:z,maxZoom:z,padding:w}).then(x)}}},[h,o,n,v,r,g,e.direction,d,s,l,i,t]),M===(v?.id??null)}function Le({nodeId:e,fitted:n,selection:o}){const a=m.useStore(d=>d.transform),r=m.useStore(d=>d.domNode),g=m.useInternalNode(e);V.useIsomorphicLayoutEffect(()=>()=>{o.placeRow(null)},[o]),V.useIsomorphicLayoutEffect(()=>{const d=r?.querySelector(`.react-flow__node[data-id="${CSS.escape(e)}"]`);n&&d instanceof HTMLElement&&o.placeRow(d)},[o,r,e,a,n]);const s=g?.measured.height;if(o.inline===null||g===void 0||s===void 0)return null;const[,l,i]=a,t=(g.internals.positionAbsolute.y+s)*i+l;return u.jsx("div",{className:"aegis-service-map__detail",style:{marginTop:Math.max(t,0)},children:o.inline})}function Oe(){const{getViewport:e,setViewport:n}=m.useReactFlow();return f.useCallback(o=>{const a=o.target;if(!(a instanceof Element)||!a.matches(".react-flow__node:focus-visible, .react-flow__edge:focus-visible"))return;const{scrollLeft:r,scrollTop:g}=o.currentTarget,s=o.currentTarget.getBoundingClientRect(),l=a.getBoundingClientRect(),i=l.left-s.left+r,t=l.top-s.top+g;if(i>=0&&t>=0&&i+l.width<=s.width&&t+l.height<=s.height)return;const{x:d,y:h,zoom:v}=e();n({x:d+s.width/2-(i+l.width/2),y:h+s.height/2-(t+l.height/2),zoom:v})},[e,n])}function De({nodes:e,edges:n,groups:o=[],direction:a="LR",height:r,fillViewport:g=!1,onNodeClick:s,onEdgeClick:l,selectedNodeId:i,focusNodeId:t,minimap:d=t===void 0,ariaLabel:h,className:v}){const M=ue.useStrings(),I=f.useId(),x=`aegis-service-map${I.replace(/:/g,"-")}`,w=s!==void 0,N=l!==void 0,[S,L]=f.useState(()=>new Map),E=f.useMemo(()=>JSON.stringify(he(e,n,o,a)),[e,n,o,a]),O=f.useMemo(()=>JSON.parse(E),[E]),_=f.useMemo(()=>_e(O,S,I),[O,S,I]),D=a==="LR",H=f.useMemo(()=>[..._.groups,...e.map(p=>{const c=[_.groupLabels.get(p.id),w?`react-flow__node-desc-${x}`:void 0].filter(Boolean).join(" ");return{id:p.id,type:"service",position:_.positions.get(p.id)??{x:0,y:0},measured:S.get(p.id),ariaLabel:p.label,ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapNodeRole,"aria-current":i===p.id?!0:void 0,"aria-describedby":c===""?void 0:c},data:{node:p,selected:i===p.id},sourcePosition:D?m.Position.Right:m.Position.Bottom,targetPosition:D?m.Position.Left:m.Position.Top,draggable:!1,connectable:!1,selectable:w,focusable:w}})],[_,e,S,i,D,w,x,M]),P=f.useMemo(()=>{const p=new Map(e.map(c=>[c.id,c.label]));return n.map(c=>({id:c.id,source:c.source,target:c.target,ariaLabel:M.serviceMapEdgeName(p.get(c.source)??c.source,p.get(c.target)??c.target),ariaRole:"group",domAttributes:{"aria-roledescription":M.serviceMapEdgeRole},type:"service",data:{edge:c},label:c.label,selectable:N,focusable:N,className:`aegis-service-map__edge aegis-service-map__edge--${c.status??"ok"}`}))},[e,n,N,M]),{getNode:F}=m.useReactFlow(),k=f.useCallback(p=>{const c=p.flatMap(b=>b.type==="dimensions"&&b.dimensions!==void 0&&F(b.id)?.type==="service"?[[b.id,b.dimensions]]:[]);L(b=>c.every(([R,T])=>b.get(R)?.width===T.width&&b.get(R)?.height===T.height)?b:new Map([...b,...c]))},[F]),y=re.useMediaQuery(Ne),A=d&&!y,$=f.useContext(le.SelectedRowDetailContext),B=je(O,_,e.every(p=>S.has(p.id)),t,A,y),C=i!==void 0&&O.ids.includes(i)?i:void 0,[q,te]=f.useState();B&&q!==C&&te(C),V.useIsomorphicLayoutEffect(()=>{if(!($===null||C===void 0||B))return $.awaitRow(),()=>{$.placeRow(null)}},[$,C,B]);const se=Oe(),oe=f.useCallback((p,c)=>{c.type==="service"&&s?.(c.data.node)},[s]),ie=f.useCallback((p,c)=>{c.data&&l?.(c.data.edge)},[l]),ne=f.useCallback(p=>{if(p.key!=="Enter"&&p.key!==" "||p.repeat)return;const c=p.target;if(!(c instanceof Element))return;const b=c.getAttribute("data-id");if(c.classList.contains("react-flow__node")){const R=e.find(T=>T.id===b);R&&s&&(p.preventDefault(),s(R))}else if(c.classList.contains("react-flow__edge")){const R=n.find(T=>T.id===b);R&&l&&(p.preventDefault(),l(R))}},[e,n,s,l]),ae={...me,height:r===void 0?void 0:`${String(r)}px`};return u.jsxs("div",{className:["aegis-service-map",g?"aegis-service-map--fill-viewport":"",v].filter(Boolean).join(" "),style:ae,children:[u.jsx("div",{className:"aegis-service-map__pane",children:u.jsxs(m.ReactFlow,{id:x,"aria-label":h,nodes:H,edges:P,nodeTypes:Se,edgeTypes:Me,minZoom:U,nodesDraggable:!1,nodesConnectable:!1,autoPanOnNodeFocus:!1,panOnDrag:!0,zoomOnScroll:!0,proOptions:{hideAttribution:!0},ariaLabelConfig:M.serviceMapAriaLabels,onNodesChange:k,onNodeClick:w?oe:void 0,onEdgeClick:N?ie:void 0,onKeyDown:ne,onFocus:se,children:[u.jsx(m.Background,{variant:m.BackgroundVariant.Dots,gap:16,size:1}),u.jsx(m.Controls,{showInteractive:!1,position:"top-left"}),A&&u.jsx(m.MiniMap,{pannable:!0,zoomable:!0,position:"bottom-right",style:{width:ee},nodeClassName:Re})]})}),$!==null&&q!==void 0&&u.jsx(Le,{nodeId:q,fitted:B,selection:$})]})}function $e(e){return u.jsx(m.ReactFlowProvider,{children:u.jsx(De,{...e})})}exports.ServiceMap=$e;
2
2
  //# sourceMappingURL=ServiceMap.cjs.map