@lincyaw/aegis-ui 0.13.0 → 0.14.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.
- package/dist/components/ui/CommitGraph.cjs +1 -1
- package/dist/components/ui/CommitGraph.cjs.map +1 -1
- package/dist/components/ui/CommitGraph.d.ts +23 -5
- package/dist/components/ui/CommitGraph.js +236 -200
- package/dist/components/ui/CommitGraph.js.map +1 -1
- package/dist/components/ui/DetailBeside.cjs +1 -1
- package/dist/components/ui/DetailBeside.cjs.map +1 -1
- package/dist/components/ui/DetailBeside.d.ts +31 -9
- package/dist/components/ui/DetailBeside.js +75 -71
- package/dist/components/ui/DetailBeside.js.map +1 -1
- package/dist/components/ui/ServiceMap.cjs +1 -1
- package/dist/components/ui/ServiceMap.cjs.map +1 -1
- package/dist/components/ui/ServiceMap.js +230 -222
- package/dist/components/ui/ServiceMap.js.map +1 -1
- package/dist/components/ui/TraceTree.cjs.map +1 -1
- package/dist/components/ui/TraceTree.d.ts +2 -1
- package/dist/components/ui/TraceTree.js.map +1 -1
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommitGraph.js","sources":["../../../src/components/ui/CommitGraph.tsx"],"sourcesContent":["import {\n type CSSProperties,\n type MouseEvent,\n type ReactNode,\n useId,\n useMemo,\n useState,\n} from 'react';\n\nimport { Tooltip } from 'antd';\n\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useStrings } from '../../locale';\nimport { Checkbox } from './Checkbox';\nimport { Chip } from './Chip';\nimport './CommitGraph.css';\n\nexport interface CommitGraphCommit {\n id: string;\n /**\n * The commit's parents. An edge to a parent missing from `commits` runs to\n * the bottom of the graph. With lanes, a parent in another lane is not\n * drawn; relate commits across lanes with `links`. A commit with two or\n * more parents drawn is a merge.\n */\n parents: string[];\n /**\n * Without `columns`: one line, cut off with an ellipsis when it is too\n * long; hovering shows it whole. It names the row's checkbox.\n */\n title?: ReactNode;\n /** Without `columns`: shown at the end of the row, e.g. a short id or a time. */\n meta?: ReactNode;\n /** Without `columns`: names that point at the commit, e.g. branch heads, as chips before the title. */\n refs?: string[];\n /**\n * With `columns`: the row's cells, by column id. A cell is one line: its\n * content is cut to the row's height, so every row lines up with the\n * drawing.\n */\n cells?: Record<string, ReactNode>;\n /** The `lanes` id of the column the commit is drawn in. Default, and for an unknown id: the first lane. */\n lane?: string;\n /**\n * Commits in other lanes this one relates to, e.g. the requirement commit a\n * run was built from. Each is drawn as a dashed edge.\n */\n links?: string[];\n}\n\nexport interface CommitGraphLane {\n id: string;\n label: string;\n}\n\nexport interface CommitGraphColumn {\n id: string;\n /** The column's name, in its header. */\n label: string;\n /**\n * Takes the width the other columns leave, which are as wide as their\n * content, and cuts its cells off with an ellipsis, e.g. a message;\n * hovering a cut cell shows it whole. Several growing columns share that\n * width evenly. A growing column is never narrower than about 20\n * characters: where the other columns leave less, the table scrolls.\n */\n grow?: boolean;\n}\n\nexport interface CommitGraphProps {\n /** The commits, newest first: each comes before its parents. */\n commits: CommitGraphCommit[];\n /**\n * Columns of the graph, each a separate history with its own branches,\n * e.g. requirements, runs and a code trunk. A commit is drawn in the lane\n * its `lane` names. Without lanes the graph is one history.\n */\n lanes?: CommitGraphLane[];\n /**\n * Draws the commits as a table: the graph in the first column, then these\n * columns, one row per commit with its `cells`. A table scrolls sideways\n * when its columns do not fit. Without `columns` the commits are a list.\n */\n columns?: CommitGraphColumn[];\n /**\n * Ids of the selected commits. With `onSelectedIdsChange`, each row has a\n * checkbox, at the start of the first column in a table, named by that\n * cell; a selected table row is `aria-selected`.\n */\n selectedIds?: string[];\n onSelectedIdsChange?: (ids: string[]) => void;\n /** The most commits selected at once: selecting one more drops the one selected first. */\n maxSelected?: number;\n /** The accessible name of the list or table of commits. */\n ariaLabel: string;\n className?: string;\n}\n\n// The SVG is drawn in px from these, and the CSS reads them from the root.\nconst ROW_HEIGHT = 36;\nconst TRACK_WIDTH = 16;\nconst LANE_MIN_WIDTH = 104;\n/** At 640 px and below, so three lanes leave the titles room. */\nconst LANE_MIN_WIDTH_NARROW = 56;\nconst DOT_RADIUS = 4;\n\nconst NARROW_QUERY = '(max-width: 640px)';\n\ninterface Edge {\n /** Rows of the commit and its parent; a missing parent is one row past the end. */\n from: number;\n to: number;\n fromX: number;\n toX: number;\n /** The x of the track the edge runs down. */\n viaX: number;\n}\n\ninterface Link {\n from: number;\n to: number;\n fromX: number;\n toX: number;\n}\n\ninterface GraphLayout {\n /** The x of each commit's dot, by row. */\n dotX: number[];\n /** Whether each commit, by row, is drawn as a merge. */\n merge: boolean[];\n /** The label of each commit's lane, by row. */\n laneLabel: Array<string | undefined>;\n edges: Edge[];\n links: Link[];\n /** Each lane's left edge and width. */\n lanes: Array<{ x: number; width: number }>;\n width: number;\n}\n\n/**\n * Places each lane's commits on tracks, git-log style: a commit takes the\n * track that expects it, its first parent continues that track, and each\n * further parent takes a free track until the parent's row.\n */\nfunction trackLane(\n laneCommits: Array<{ commit: CommitGraphCommit; row: number }>,\n rowOf: Map<string, number>,\n inLane: (id: string) => boolean,\n): {\n trackOf: Map<number, number>;\n edges: Array<{ from: number; to: number; via: number; parent: string }>;\n tracks: number;\n} {\n const expected: Array<string | null> = [];\n const trackOf = new Map<number, number>();\n const edges: Array<{\n from: number;\n to: number;\n via: number;\n parent: string;\n }> = [];\n const free = (): number => {\n const index = expected.indexOf(null);\n return index === -1 ? expected.length : index;\n };\n let tracks = 0;\n for (const { commit, row } of laneCommits) {\n const waiting = expected.flatMap((id, index) =>\n id === commit.id ? [index] : [],\n );\n waiting.forEach((index) => {\n expected[index] = null;\n });\n const track = waiting.length > 0 ? waiting[0] : free();\n expected[track] = null;\n trackOf.set(row, track);\n commit.parents\n .filter((parent) => !rowOf.has(parent) || inLane(parent))\n .forEach((parent, index) => {\n const waitingTrack = expected.indexOf(parent);\n const via =\n index === 0 ? track : waitingTrack === -1 ? free() : waitingTrack;\n expected[via] = parent;\n edges.push({ from: row, to: rowOf.get(parent) ?? -1, via, parent });\n });\n tracks = Math.max(tracks, expected.length, track + 1);\n }\n return { trackOf, edges, tracks };\n}\n\nfunction layoutGraph(\n commits: CommitGraphCommit[],\n lanes: CommitGraphLane[] | undefined,\n laneMinWidth: number,\n): GraphLayout {\n const rowOf = new Map(commits.map((commit, row) => [commit.id, row]));\n const laneIds = lanes?.map((lane) => lane.id) ?? [undefined];\n const known = new Set(laneIds);\n const laneOf = (commit: CommitGraphCommit): string | undefined =>\n known.has(commit.lane) ? commit.lane : laneIds[0];\n const dotX = commits.map(() => 0);\n const laneLabel = commits.map((): string | undefined => undefined);\n const edges: Edge[] = [];\n const laneBoxes: GraphLayout['lanes'] = [];\n let x = 0;\n for (const [index, laneId] of laneIds.entries()) {\n const laneCommits = commits.flatMap((commit, row) =>\n laneOf(commit) === laneId ? [{ commit, row }] : [],\n );\n laneCommits.forEach(({ row }) => {\n laneLabel[row] = lanes?.[index].label;\n });\n const laneIdsOf = new Set(laneCommits.map(({ commit }) => commit.id));\n const placed = trackLane(laneCommits, rowOf, (id) => laneIdsOf.has(id));\n const tracksWidth = Math.max(placed.tracks, 1) * TRACK_WIDTH;\n const width =\n lanes === undefined ? tracksWidth : Math.max(tracksWidth, laneMinWidth);\n const trackX = (track: number): number =>\n x + (width - tracksWidth) / 2 + (track + 0.5) * TRACK_WIDTH;\n placed.trackOf.forEach((track, row) => {\n dotX[row] = trackX(track);\n });\n placed.edges.forEach((edge) => {\n const to = edge.to === -1 ? commits.length : edge.to;\n edges.push({\n from: edge.from,\n to,\n fromX: dotX[edge.from],\n toX:\n edge.to === -1\n ? trackX(edge.via)\n : trackX(placed.trackOf.get(to) ?? 0),\n viaX: trackX(edge.via),\n });\n });\n laneBoxes.push({ x, width });\n x += width;\n }\n const links = commits.flatMap((commit, row) =>\n (commit.links ?? []).flatMap((target) => {\n const to = rowOf.get(target);\n return to === undefined\n ? []\n : [{ from: row, to, fromX: dotX[row], toX: dotX[to] }];\n }),\n );\n const drawnParents = new Map<number, number>();\n edges.forEach((edge) => {\n drawnParents.set(edge.from, (drawnParents.get(edge.from) ?? 0) + 1);\n });\n const merge = commits.map((_, row) => (drawnParents.get(row) ?? 0) > 1);\n return { dotX, merge, laneLabel, edges, links, lanes: laneBoxes, width: x };\n}\n\nconst rowY = (row: number): number => (row + 0.5) * ROW_HEIGHT;\n\n/** A curve that leaves and enters vertically. */\nfunction bend(x1: number, y1: number, x2: number, y2: number): string {\n const middle = (y1 + y2) / 2;\n return `C ${String(x1)} ${String(middle)} ${String(x2)} ${String(middle)} ${String(x2)} ${String(y2)}`;\n}\n\n/**\n * An edge leaves its commit for its track within one row, runs down the\n * track, and enters its parent within the last row.\n */\nfunction edgePath({ from, to, fromX, toX, viaX }: Edge): string {\n const start = `M ${String(fromX)} ${String(rowY(from))}`;\n if (to - from <= 1) {\n return `${start} ${bend(fromX, rowY(from), toX, rowY(to))}`;\n }\n const out =\n viaX === fromX ? '' : bend(fromX, rowY(from), viaX, rowY(from + 1));\n const down = `L ${String(viaX)} ${String(rowY(to - 1))}`;\n const into =\n viaX === toX\n ? `L ${String(toX)} ${String(rowY(to))}`\n : bend(viaX, rowY(to - 1), toX, rowY(to));\n return [start, out, down, into].filter(Boolean).join(' ');\n}\n\n/** Text cut off with an ellipsis, shown whole on hover only when it is cut. */\nfunction CutText({\n id,\n className,\n children,\n}: {\n id?: string;\n className: string;\n children: ReactNode;\n}): JSX.Element {\n const [cut, setCut] = useState(false);\n return (\n <Tooltip\n placement=\"topLeft\"\n mouseEnterDelay={0.3}\n styles={{ root: { maxWidth: 'var(--tooltip-max-width)' } }}\n title={cut ? children : undefined}\n >\n <span\n id={id}\n className={className}\n onMouseEnter={(event: MouseEvent<HTMLSpanElement>) => {\n setCut(\n event.currentTarget.scrollWidth > event.currentTarget.clientWidth,\n );\n }}\n >\n {children}\n </span>\n </Tooltip>\n );\n}\n\n/**\n * What a row's drawing shows and assistive technology does not read: the\n * commit's lane and whether it is a merge. The row names these hidden spans\n * as its description.\n */\nfunction rowDescription(\n idPrefix: string,\n row: number,\n layout: GraphLayout,\n mergeText: string,\n): { describedBy: string | undefined; spans: ReactNode } {\n const lane = layout.laneLabel[row];\n const merge = layout.merge[row];\n const laneId = `${idPrefix}-lane-${String(row)}`;\n const mergeId = `${idPrefix}-merge-${String(row)}`;\n const ids = [lane === undefined ? '' : laneId, merge ? mergeId : ''].filter(\n Boolean,\n );\n return {\n describedBy: ids.length === 0 ? undefined : ids.join(' '),\n spans: (\n <>\n {lane !== undefined && (\n <span id={laneId} hidden>\n {lane}\n </span>\n )}\n {merge && (\n <span id={mergeId} hidden>\n {mergeText}\n </span>\n )}\n </>\n ),\n };\n}\n\n/** The edges, links and dots, drawn over the rows; assistive technology reads the rows. */\nfunction GraphDrawing({\n commits,\n layout,\n selected,\n}: {\n commits: CommitGraphCommit[];\n layout: GraphLayout;\n selected: ReadonlySet<string>;\n}): JSX.Element {\n const height = commits.length * ROW_HEIGHT;\n return (\n <svg\n className=\"aegis-commit-graph__svg\"\n width={layout.width}\n height={height}\n viewBox={`0 0 ${String(layout.width)} ${String(height)}`}\n aria-hidden=\"true\"\n >\n {layout.lanes.slice(1).map((lane) => (\n <line\n key={lane.x}\n className=\"aegis-commit-graph__lane-rule\"\n x1={lane.x}\n x2={lane.x}\n y1={0}\n y2={height}\n />\n ))}\n {layout.links.map((link) => (\n <path\n key={`${String(link.from)}-${String(link.to)}`}\n className=\"aegis-commit-graph__link\"\n d={`M ${String(link.fromX)} ${String(rowY(link.from))} ${bend(link.fromX, rowY(link.from), link.toX, rowY(link.to))}`}\n />\n ))}\n {layout.edges.map((edge) => (\n <path\n key={`${String(edge.from)}-${String(edge.to)}-${String(edge.viaX)}`}\n className=\"aegis-commit-graph__edge\"\n d={edgePath(edge)}\n />\n ))}\n {commits.map((commit, row) => (\n <circle\n key={commit.id}\n className={[\n 'aegis-commit-graph__dot',\n layout.merge[row] ? 'aegis-commit-graph__dot--merge' : '',\n selected.has(commit.id) ? 'aegis-commit-graph__dot--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n cx={layout.dotX[row]}\n cy={rowY(row)}\n r={DOT_RADIUS}\n />\n ))}\n </svg>\n );\n}\n\nfunction LaneLabels({\n lanes,\n layout,\n}: {\n lanes: CommitGraphLane[];\n layout: GraphLayout;\n}): JSX.Element {\n return (\n <span className=\"aegis-commit-graph__lane-labels\">\n {lanes.map((lane, index) => (\n <span\n key={lane.id}\n className=\"aegis-commit-graph__lane-label\"\n style={{ width: `${String(layout.lanes[index].width)}px` }}\n >\n {lane.label}\n </span>\n ))}\n </span>\n );\n}\n\n/** What the list and the table both draw from. */\ninterface RowsProps {\n commits: CommitGraphCommit[];\n lanes: CommitGraphLane[] | undefined;\n layout: GraphLayout;\n selected: ReadonlySet<string>;\n /** Set when the rows have checkboxes. */\n toggle: ((id: string, checked: boolean) => void) | undefined;\n ariaLabel: string;\n}\n\nfunction CommitList({\n commits,\n lanes,\n layout,\n selected,\n toggle,\n ariaLabel,\n}: RowsProps): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n return (\n <>\n {lanes !== undefined && (\n <div className=\"aegis-commit-graph__lanes\" aria-hidden=\"true\">\n <span className=\"aegis-commit-graph__lane-spacer\" />\n <LaneLabels lanes={lanes} layout={layout} />\n </div>\n )}\n <div className=\"aegis-commit-graph__body\">\n <GraphDrawing commits={commits} layout={layout} selected={selected} />\n <ol className=\"aegis-commit-graph__rows\" aria-label={ariaLabel}>\n {commits.map((commit, row) => {\n const isSelected = selected.has(commit.id);\n const titleId = `${idPrefix}-title-${String(row)}`;\n const description = rowDescription(\n idPrefix,\n row,\n layout,\n strings.mergeCommit,\n );\n return (\n <li\n key={commit.id}\n className={\n isSelected\n ? 'aegis-commit-graph__row aegis-commit-graph__row--selected'\n : 'aegis-commit-graph__row'\n }\n aria-describedby={description.describedBy}\n >\n <span className=\"aegis-commit-graph__select\">\n {toggle !== undefined && (\n <Checkbox\n checked={isSelected}\n onChange={(checked) => {\n toggle(commit.id, checked);\n }}\n aria-labelledby={titleId}\n />\n )}\n </span>\n <span className=\"aegis-commit-graph__text\">\n {description.spans}\n {commit.refs?.map((ref) => (\n <Chip key={ref} className=\"aegis-commit-graph__ref\">\n {ref}\n </Chip>\n ))}\n <CutText id={titleId} className=\"aegis-commit-graph__title\">\n {commit.title}\n </CutText>\n </span>\n {commit.meta !== undefined && (\n <span className=\"aegis-commit-graph__meta\">\n {commit.meta}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </div>\n </>\n );\n}\n\nfunction CommitTable({\n commits,\n lanes,\n layout,\n selected,\n toggle,\n ariaLabel,\n columns,\n}: RowsProps & { columns: CommitGraphColumn[] }): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n return (\n <div className=\"aegis-commit-graph__scroll\">\n <table className=\"aegis-commit-graph__table\" aria-label={ariaLabel}>\n <thead>\n <tr>\n <th\n scope=\"col\"\n className=\"aegis-commit-graph__th aegis-commit-graph__th--graph\"\n aria-hidden=\"true\"\n >\n {lanes !== undefined && (\n <LaneLabels lanes={lanes} layout={layout} />\n )}\n </th>\n {columns.map((column) => (\n <th\n key={column.id}\n scope=\"col\"\n className=\"aegis-commit-graph__th\"\n >\n {column.label}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {commits.map((commit, row) => {\n const isSelected = selected.has(commit.id);\n const firstId = `${idPrefix}-first-${String(row)}`;\n const description = rowDescription(\n idPrefix,\n row,\n layout,\n strings.mergeCommit,\n );\n return (\n <tr\n key={commit.id}\n className={\n isSelected\n ? 'aegis-commit-graph__tr aegis-commit-graph__tr--selected'\n : 'aegis-commit-graph__tr'\n }\n aria-selected={toggle === undefined ? undefined : isSelected}\n aria-describedby={description.describedBy}\n >\n <td\n className={\n row === 0\n ? 'aegis-commit-graph__td aegis-commit-graph__td--graph aegis-commit-graph__td--drawing'\n : 'aegis-commit-graph__td aegis-commit-graph__td--graph'\n }\n aria-hidden=\"true\"\n >\n {description.spans}\n {row === 0 && (\n <GraphDrawing\n commits={commits}\n layout={layout}\n selected={selected}\n />\n )}\n </td>\n {columns.map((column, index) => {\n const content =\n index === 0 ? (\n <>\n {toggle !== undefined && (\n <span className=\"aegis-commit-graph__cell-select\">\n <Checkbox\n checked={isSelected}\n onChange={(checked) => {\n toggle(commit.id, checked);\n }}\n aria-labelledby={firstId}\n />\n </span>\n )}\n <span id={firstId}>{commit.cells?.[column.id]}</span>\n </>\n ) : (\n commit.cells?.[column.id]\n );\n return column.grow === true ? (\n <td\n key={column.id}\n className=\"aegis-commit-graph__td aegis-commit-graph__td--grow\"\n >\n <CutText className=\"aegis-commit-graph__cell\">\n {content}\n </CutText>\n </td>\n ) : (\n <td key={column.id} className=\"aegis-commit-graph__td\">\n <span className=\"aegis-commit-graph__cell\">\n {content}\n </span>\n </td>\n );\n })}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport function CommitGraph({\n commits,\n lanes,\n columns,\n selectedIds = [],\n onSelectedIdsChange,\n maxSelected,\n ariaLabel,\n className,\n}: CommitGraphProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const laneMinWidth = narrow ? LANE_MIN_WIDTH_NARROW : LANE_MIN_WIDTH;\n const layout = useMemo(\n () => layoutGraph(commits, lanes, laneMinWidth),\n [commits, lanes, laneMinWidth],\n );\n const toggle =\n onSelectedIdsChange === undefined\n ? undefined\n : (id: string, checked: boolean): void => {\n const next = checked\n ? [...selectedIds.filter((each) => each !== id), id]\n : selectedIds.filter((each) => each !== id);\n onSelectedIdsChange(\n maxSelected === undefined ? next : next.slice(-maxSelected),\n );\n };\n const rows: RowsProps = {\n commits,\n lanes,\n layout,\n selected: new Set(selectedIds),\n toggle,\n ariaLabel,\n };\n\n const cls = [\n 'aegis-commit-graph',\n // The list's checkboxes take a column of their own; the table's sit in its first column.\n toggle !== undefined && columns === undefined\n ? 'aegis-commit-graph--selectable'\n : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n const rootStyle = {\n '--aegis-commit-graph-row-h': `${String(ROW_HEIGHT)}px`,\n '--aegis-commit-graph-graph-w': `${String(layout.width)}px`,\n '--aegis-commit-graph-grow-count': String(\n columns?.filter((column) => column.grow === true).length ?? 0,\n ),\n } as CSSProperties;\n\n return (\n <div className={cls} style={rootStyle}>\n {columns === undefined ? (\n <CommitList {...rows} />\n ) : (\n <CommitTable {...rows} columns={columns} />\n )}\n </div>\n );\n}\n"],"names":["ROW_HEIGHT","TRACK_WIDTH","LANE_MIN_WIDTH","LANE_MIN_WIDTH_NARROW","DOT_RADIUS","NARROW_QUERY","trackLane","laneCommits","rowOf","inLane","expected","trackOf","edges","free","index","tracks","commit","row","waiting","id","track","parent","waitingTrack","via","layoutGraph","commits","lanes","laneMinWidth","laneIds","lane","known","laneOf","dotX","laneLabel","laneBoxes","x","laneId","laneIdsOf","placed","tracksWidth","width","trackX","edge","to","links","target","drawnParents","merge","_","rowY","bend","x1","y1","x2","y2","middle","edgePath","from","fromX","toX","viaX","start","out","down","into","CutText","className","children","cut","setCut","useState","jsx","Tooltip","event","rowDescription","idPrefix","layout","mergeText","mergeId","ids","jsxs","Fragment","GraphDrawing","selected","height","link","LaneLabels","CommitList","toggle","ariaLabel","strings","useStrings","useId","isSelected","titleId","description","Checkbox","checked","ref","Chip","CommitTable","columns","column","firstId","content","CommitGraph","selectedIds","onSelectedIdsChange","maxSelected","useMediaQuery","useMemo","next","each","rows","cls","rootStyle"],"mappings":";;;;;;;;AAmGA,MAAMA,IAAa,IACbC,IAAc,IACdC,IAAiB,KAEjBC,IAAwB,IACxBC,IAAa,GAEbC,IAAe;AAsCrB,SAASC,EACPC,GACAC,GACAC,GAKA;AACA,QAAMC,IAAiC,CAAA,GACjCC,wBAAc,IAAA,GACdC,IAKD,CAAA,GACCC,IAAO,MAAc;AACzB,UAAMC,IAAQJ,EAAS,QAAQ,IAAI;AACnC,WAAOI,MAAU,KAAKJ,EAAS,SAASI;AAAA,EAC1C;AACA,MAA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AAEJ;"}
|
|
1
|
+
{"version":3,"file":"CommitGraph.js","sources":["../../../src/components/ui/CommitGraph.tsx"],"sourcesContent":["import {\n type CSSProperties,\n Fragment,\n type MouseEvent,\n type ReactNode,\n useId,\n useMemo,\n useState,\n} from 'react';\n\nimport { Tooltip } from 'antd';\n\nimport { useMediaQuery } from '../../hooks/useMediaQuery';\nimport { useStrings } from '../../locale';\nimport { Checkbox } from './Checkbox';\nimport { Chip } from './Chip';\nimport './CommitGraph.css';\n\n/** One part of a table cell given as parts. */\nexport interface CommitGraphCellPart {\n content: ReactNode;\n /**\n * Text that gives way in a growing column: it is cut off with an\n * ellipsis, down to little more than the ellipsis. A part without it,\n * such as a link, keeps its whole width.\n */\n cut?: boolean;\n}\n\n/** A table cell as parts on one line, in order, a small gap apart. */\nexport interface CommitGraphPartsCell {\n parts: CommitGraphCellPart[];\n}\n\nexport interface CommitGraphCommit {\n id: string;\n /**\n * The commit's parents. An edge to a parent missing from `commits` runs to\n * the bottom of the graph. With lanes, a parent in another lane is not\n * drawn; relate commits across lanes with `links`. A commit with two or\n * more parents drawn is a merge.\n */\n parents: string[];\n /**\n * Without `columns`: one line, cut off with an ellipsis when it is too\n * long; hovering shows it whole. It names the row's checkbox.\n */\n title?: ReactNode;\n /** Without `columns`: shown at the end of the row, e.g. a short id or a time. */\n meta?: ReactNode;\n /** Without `columns`: names that point at the commit, e.g. branch heads, as chips before the title. */\n refs?: string[];\n /**\n * With `columns`: the row's cells, by column id. A cell is one line: its\n * content is cut to the row's height, so every row lines up with the\n * drawing. A cell given as parts keeps every part whole except, in a\n * growing column, the `cut` ones, so its links never disappear; the\n * column is at least as wide as the parts it keeps.\n */\n cells?: Record<string, ReactNode | CommitGraphPartsCell>;\n /** The `lanes` id of the column the commit is drawn in. Default, and for an unknown id: the first lane. */\n lane?: string;\n /**\n * Commits in other lanes this one relates to, e.g. the requirement commit a\n * run was built from. Each is drawn as a dashed edge.\n */\n links?: string[];\n}\n\nexport interface CommitGraphLane {\n id: string;\n label: string;\n}\n\nexport interface CommitGraphColumn {\n id: string;\n /** The column's name, in its header. */\n label: string;\n /**\n * Takes the width the other columns leave, which are as wide as their\n * content, and cuts its cells off with an ellipsis, e.g. a message;\n * hovering a cut cell shows it whole. A cell given as parts gives way\n * only in its `cut` parts. Several growing columns share that width\n * evenly. A growing column is never narrower than about 20 characters,\n * nor than the parts its cells keep: where the other columns leave\n * less, the table scrolls.\n */\n grow?: boolean;\n}\n\nexport interface CommitGraphProps {\n /** The commits, newest first: each comes before its parents. */\n commits: CommitGraphCommit[];\n /**\n * Columns of the graph, each a separate history with its own branches,\n * e.g. requirements, runs and a code trunk. A commit is drawn in the lane\n * its `lane` names. Without lanes the graph is one history.\n */\n lanes?: CommitGraphLane[];\n /**\n * Draws the commits as a table: the graph in the first column, then these\n * columns, one row per commit with its `cells`. A table scrolls sideways\n * when its columns do not fit. Without `columns` the commits are a list.\n */\n columns?: CommitGraphColumn[];\n /**\n * Ids of the selected commits. With `onSelectedIdsChange`, each row has a\n * checkbox, at the start of the first column in a table, named by that\n * cell; a selected table row is `aria-selected`.\n */\n selectedIds?: string[];\n onSelectedIdsChange?: (ids: string[]) => void;\n /** The most commits selected at once: selecting one more drops the one selected first. */\n maxSelected?: number;\n /** The accessible name of the list or table of commits. */\n ariaLabel: string;\n className?: string;\n}\n\n// The SVG is drawn in px from these, and the CSS reads them from the root.\nconst ROW_HEIGHT = 36;\nconst TRACK_WIDTH = 16;\nconst LANE_MIN_WIDTH = 104;\n/** At 640 px and below, so three lanes leave the titles room. */\nconst LANE_MIN_WIDTH_NARROW = 56;\nconst DOT_RADIUS = 4;\n\nconst NARROW_QUERY = '(max-width: 640px)';\n\nconst CUT_PART_CLASS = 'aegis-commit-graph__part--cut';\n\ninterface Edge {\n /** Rows of the commit and its parent; a missing parent is one row past the end. */\n from: number;\n to: number;\n fromX: number;\n toX: number;\n /** The x of the track the edge runs down. */\n viaX: number;\n}\n\ninterface Link {\n from: number;\n to: number;\n fromX: number;\n toX: number;\n}\n\ninterface GraphLayout {\n /** The x of each commit's dot, by row. */\n dotX: number[];\n /** Whether each commit, by row, is drawn as a merge. */\n merge: boolean[];\n /** The label of each commit's lane, by row. */\n laneLabel: Array<string | undefined>;\n edges: Edge[];\n links: Link[];\n /** Each lane's left edge and width. */\n lanes: Array<{ x: number; width: number }>;\n width: number;\n}\n\n/**\n * Places each lane's commits on tracks, git-log style: a commit takes the\n * track that expects it, its first parent continues that track, and each\n * further parent takes a free track until the parent's row.\n */\nfunction trackLane(\n laneCommits: Array<{ commit: CommitGraphCommit; row: number }>,\n rowOf: Map<string, number>,\n inLane: (id: string) => boolean,\n): {\n trackOf: Map<number, number>;\n edges: Array<{ from: number; to: number; via: number; parent: string }>;\n tracks: number;\n} {\n const expected: Array<string | null> = [];\n const trackOf = new Map<number, number>();\n const edges: Array<{\n from: number;\n to: number;\n via: number;\n parent: string;\n }> = [];\n const free = (): number => {\n const index = expected.indexOf(null);\n return index === -1 ? expected.length : index;\n };\n let tracks = 0;\n for (const { commit, row } of laneCommits) {\n const waiting = expected.flatMap((id, index) =>\n id === commit.id ? [index] : [],\n );\n waiting.forEach((index) => {\n expected[index] = null;\n });\n const track = waiting.length > 0 ? waiting[0] : free();\n expected[track] = null;\n trackOf.set(row, track);\n commit.parents\n .filter((parent) => !rowOf.has(parent) || inLane(parent))\n .forEach((parent, index) => {\n const waitingTrack = expected.indexOf(parent);\n const via =\n index === 0 ? track : waitingTrack === -1 ? free() : waitingTrack;\n expected[via] = parent;\n edges.push({ from: row, to: rowOf.get(parent) ?? -1, via, parent });\n });\n tracks = Math.max(tracks, expected.length, track + 1);\n }\n return { trackOf, edges, tracks };\n}\n\nfunction layoutGraph(\n commits: CommitGraphCommit[],\n lanes: CommitGraphLane[] | undefined,\n laneMinWidth: number,\n): GraphLayout {\n const rowOf = new Map(commits.map((commit, row) => [commit.id, row]));\n const laneIds = lanes?.map((lane) => lane.id) ?? [undefined];\n const known = new Set(laneIds);\n const laneOf = (commit: CommitGraphCommit): string | undefined =>\n known.has(commit.lane) ? commit.lane : laneIds[0];\n const dotX = commits.map(() => 0);\n const laneLabel = commits.map((): string | undefined => undefined);\n const edges: Edge[] = [];\n const laneBoxes: GraphLayout['lanes'] = [];\n let x = 0;\n for (const [index, laneId] of laneIds.entries()) {\n const laneCommits = commits.flatMap((commit, row) =>\n laneOf(commit) === laneId ? [{ commit, row }] : [],\n );\n laneCommits.forEach(({ row }) => {\n laneLabel[row] = lanes?.[index].label;\n });\n const laneIdsOf = new Set(laneCommits.map(({ commit }) => commit.id));\n const placed = trackLane(laneCommits, rowOf, (id) => laneIdsOf.has(id));\n const tracksWidth = Math.max(placed.tracks, 1) * TRACK_WIDTH;\n const width =\n lanes === undefined ? tracksWidth : Math.max(tracksWidth, laneMinWidth);\n const trackX = (track: number): number =>\n x + (width - tracksWidth) / 2 + (track + 0.5) * TRACK_WIDTH;\n placed.trackOf.forEach((track, row) => {\n dotX[row] = trackX(track);\n });\n placed.edges.forEach((edge) => {\n const to = edge.to === -1 ? commits.length : edge.to;\n edges.push({\n from: edge.from,\n to,\n fromX: dotX[edge.from],\n toX:\n edge.to === -1\n ? trackX(edge.via)\n : trackX(placed.trackOf.get(to) ?? 0),\n viaX: trackX(edge.via),\n });\n });\n laneBoxes.push({ x, width });\n x += width;\n }\n const links = commits.flatMap((commit, row) =>\n (commit.links ?? []).flatMap((target) => {\n const to = rowOf.get(target);\n return to === undefined\n ? []\n : [{ from: row, to, fromX: dotX[row], toX: dotX[to] }];\n }),\n );\n const drawnParents = new Map<number, number>();\n edges.forEach((edge) => {\n drawnParents.set(edge.from, (drawnParents.get(edge.from) ?? 0) + 1);\n });\n const merge = commits.map((_, row) => (drawnParents.get(row) ?? 0) > 1);\n return { dotX, merge, laneLabel, edges, links, lanes: laneBoxes, width: x };\n}\n\nconst rowY = (row: number): number => (row + 0.5) * ROW_HEIGHT;\n\n/** A curve that leaves and enters vertically. */\nfunction bend(x1: number, y1: number, x2: number, y2: number): string {\n const middle = (y1 + y2) / 2;\n return `C ${String(x1)} ${String(middle)} ${String(x2)} ${String(middle)} ${String(x2)} ${String(y2)}`;\n}\n\n/**\n * An edge leaves its commit for its track within one row, runs down the\n * track, and enters its parent within the last row.\n */\nfunction edgePath({ from, to, fromX, toX, viaX }: Edge): string {\n const start = `M ${String(fromX)} ${String(rowY(from))}`;\n if (to - from <= 1) {\n return `${start} ${bend(fromX, rowY(from), toX, rowY(to))}`;\n }\n const out =\n viaX === fromX ? '' : bend(fromX, rowY(from), viaX, rowY(from + 1));\n const down = `L ${String(viaX)} ${String(rowY(to - 1))}`;\n const into =\n viaX === toX\n ? `L ${String(toX)} ${String(rowY(to))}`\n : bend(viaX, rowY(to - 1), toX, rowY(to));\n return [start, out, down, into].filter(Boolean).join(' ');\n}\n\n/**\n * Text cut off with an ellipsis, shown whole on hover only when it or one\n * of its cut parts is cut. `whole` is what the hover shows; default: the\n * text itself.\n */\nfunction CutText({\n id,\n className,\n whole,\n children,\n}: {\n id?: string;\n className: string;\n whole?: ReactNode;\n children: ReactNode;\n}): JSX.Element {\n const [cut, setCut] = useState(false);\n return (\n <Tooltip\n placement=\"topLeft\"\n mouseEnterDelay={0.3}\n styles={{ root: { maxWidth: 'var(--tooltip-max-width)' } }}\n title={cut ? (whole ?? children) : undefined}\n >\n <span\n id={id}\n className={className}\n onMouseEnter={(event: MouseEvent<HTMLSpanElement>) => {\n const text = event.currentTarget;\n setCut(\n [\n text,\n ...text.querySelectorAll<HTMLElement>(`.${CUT_PART_CLASS}`),\n ].some((box) => box.scrollWidth > box.clientWidth),\n );\n }}\n >\n {children}\n </span>\n </Tooltip>\n );\n}\n\n/**\n * What a row's drawing shows and assistive technology does not read: the\n * commit's lane and whether it is a merge. The row names these hidden spans\n * as its description.\n */\nfunction rowDescription(\n idPrefix: string,\n row: number,\n layout: GraphLayout,\n mergeText: string,\n): { describedBy: string | undefined; spans: ReactNode } {\n const lane = layout.laneLabel[row];\n const merge = layout.merge[row];\n const laneId = `${idPrefix}-lane-${String(row)}`;\n const mergeId = `${idPrefix}-merge-${String(row)}`;\n const ids = [lane === undefined ? '' : laneId, merge ? mergeId : ''].filter(\n Boolean,\n );\n return {\n describedBy: ids.length === 0 ? undefined : ids.join(' '),\n spans: (\n <>\n {lane !== undefined && (\n <span id={laneId} hidden>\n {lane}\n </span>\n )}\n {merge && (\n <span id={mergeId} hidden>\n {mergeText}\n </span>\n )}\n </>\n ),\n };\n}\n\n/** The edges, links and dots, drawn over the rows; assistive technology reads the rows. */\nfunction GraphDrawing({\n commits,\n layout,\n selected,\n}: {\n commits: CommitGraphCommit[];\n layout: GraphLayout;\n selected: ReadonlySet<string>;\n}): JSX.Element {\n const height = commits.length * ROW_HEIGHT;\n return (\n <svg\n className=\"aegis-commit-graph__svg\"\n width={layout.width}\n height={height}\n viewBox={`0 0 ${String(layout.width)} ${String(height)}`}\n aria-hidden=\"true\"\n >\n {layout.lanes.slice(1).map((lane) => (\n <line\n key={lane.x}\n className=\"aegis-commit-graph__lane-rule\"\n x1={lane.x}\n x2={lane.x}\n y1={0}\n y2={height}\n />\n ))}\n {layout.links.map((link) => (\n <path\n key={`${String(link.from)}-${String(link.to)}`}\n className=\"aegis-commit-graph__link\"\n d={`M ${String(link.fromX)} ${String(rowY(link.from))} ${bend(link.fromX, rowY(link.from), link.toX, rowY(link.to))}`}\n />\n ))}\n {layout.edges.map((edge) => (\n <path\n key={`${String(edge.from)}-${String(edge.to)}-${String(edge.viaX)}`}\n className=\"aegis-commit-graph__edge\"\n d={edgePath(edge)}\n />\n ))}\n {commits.map((commit, row) => (\n <circle\n key={commit.id}\n className={[\n 'aegis-commit-graph__dot',\n layout.merge[row] ? 'aegis-commit-graph__dot--merge' : '',\n selected.has(commit.id) ? 'aegis-commit-graph__dot--selected' : '',\n ]\n .filter(Boolean)\n .join(' ')}\n cx={layout.dotX[row]}\n cy={rowY(row)}\n r={DOT_RADIUS}\n />\n ))}\n </svg>\n );\n}\n\nfunction LaneLabels({\n lanes,\n layout,\n}: {\n lanes: CommitGraphLane[];\n layout: GraphLayout;\n}): JSX.Element {\n return (\n <span className=\"aegis-commit-graph__lane-labels\">\n {lanes.map((lane, index) => (\n <span\n key={lane.id}\n className=\"aegis-commit-graph__lane-label\"\n style={{ width: `${String(layout.lanes[index].width)}px` }}\n >\n {lane.label}\n </span>\n ))}\n </span>\n );\n}\n\n/** What the list and the table both draw from. */\ninterface RowsProps {\n commits: CommitGraphCommit[];\n lanes: CommitGraphLane[] | undefined;\n layout: GraphLayout;\n selected: ReadonlySet<string>;\n /** Set when the rows have checkboxes. */\n toggle: ((id: string, checked: boolean) => void) | undefined;\n ariaLabel: string;\n}\n\nfunction CommitList({\n commits,\n lanes,\n layout,\n selected,\n toggle,\n ariaLabel,\n}: RowsProps): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n return (\n <>\n {lanes !== undefined && (\n <div className=\"aegis-commit-graph__lanes\" aria-hidden=\"true\">\n <span className=\"aegis-commit-graph__lane-spacer\" />\n <LaneLabels lanes={lanes} layout={layout} />\n </div>\n )}\n <div className=\"aegis-commit-graph__body\">\n <GraphDrawing commits={commits} layout={layout} selected={selected} />\n <ol className=\"aegis-commit-graph__rows\" aria-label={ariaLabel}>\n {commits.map((commit, row) => {\n const isSelected = selected.has(commit.id);\n const titleId = `${idPrefix}-title-${String(row)}`;\n const description = rowDescription(\n idPrefix,\n row,\n layout,\n strings.mergeCommit,\n );\n return (\n <li\n key={commit.id}\n className={\n isSelected\n ? 'aegis-commit-graph__row aegis-commit-graph__row--selected'\n : 'aegis-commit-graph__row'\n }\n aria-describedby={description.describedBy}\n >\n <span className=\"aegis-commit-graph__select\">\n {toggle !== undefined && (\n <Checkbox\n checked={isSelected}\n onChange={(checked) => {\n toggle(commit.id, checked);\n }}\n aria-labelledby={titleId}\n />\n )}\n </span>\n <span className=\"aegis-commit-graph__text\">\n {description.spans}\n {commit.refs?.map((ref) => (\n <Chip key={ref} className=\"aegis-commit-graph__ref\">\n {ref}\n </Chip>\n ))}\n <CutText id={titleId} className=\"aegis-commit-graph__title\">\n {commit.title}\n </CutText>\n </span>\n {commit.meta !== undefined && (\n <span className=\"aegis-commit-graph__meta\">\n {commit.meta}\n </span>\n )}\n </li>\n );\n })}\n </ol>\n </div>\n </>\n );\n}\n\nfunction isCellParts(\n cell: ReactNode | CommitGraphPartsCell,\n): cell is CommitGraphPartsCell {\n return typeof cell === 'object' && cell !== null && 'parts' in cell;\n}\n\n/**\n * One cell of the table. A cell given as parts draws them on one line; in a\n * growing column only its cut parts give way, it is at least as wide as the\n * parts it keeps, and its hover shows the parts as one line of text.\n */\nfunction TableCell({\n cell,\n grow,\n id,\n select,\n}: {\n cell: ReactNode | CommitGraphPartsCell;\n grow: boolean;\n /** Set on the first column's content, which names the row's checkbox. */\n id: string | undefined;\n /** The row's checkbox, at the start of the first column. */\n select: ReactNode;\n}): JSX.Element {\n const shape = isCellParts(cell)\n ? {\n value: (\n <span id={id} className=\"aegis-commit-graph__parts\">\n {cell.parts.map((part, at) => (\n <span\n key={at}\n className={\n part.cut === true\n ? `aegis-commit-graph__part ${CUT_PART_CLASS}`\n : 'aegis-commit-graph__part'\n }\n >\n {part.content}\n </span>\n ))}\n </span>\n ),\n whole: cell.parts.map((part, at) => (\n <Fragment key={at}>\n {at > 0 && ' '}\n {part.content}\n </Fragment>\n )),\n cellClass: 'aegis-commit-graph__cell aegis-commit-graph__cell--parts',\n growClass:\n 'aegis-commit-graph__td aegis-commit-graph__td--grow aegis-commit-graph__td--parts',\n }\n : {\n value: id === undefined ? cell : <span id={id}>{cell}</span>,\n whole: undefined,\n cellClass: 'aegis-commit-graph__cell',\n growClass: 'aegis-commit-graph__td aegis-commit-graph__td--grow',\n };\n const content = (\n <>\n {select}\n {shape.value}\n </>\n );\n return grow ? (\n <td className={shape.growClass}>\n <CutText className={shape.cellClass} whole={shape.whole}>\n {content}\n </CutText>\n </td>\n ) : (\n <td className=\"aegis-commit-graph__td\">\n <span className={shape.cellClass}>{content}</span>\n </td>\n );\n}\n\nfunction CommitTable({\n commits,\n lanes,\n layout,\n selected,\n toggle,\n ariaLabel,\n columns,\n}: RowsProps & { columns: CommitGraphColumn[] }): JSX.Element {\n const strings = useStrings();\n const idPrefix = useId();\n return (\n <div className=\"aegis-commit-graph__scroll\">\n <table className=\"aegis-commit-graph__table\" aria-label={ariaLabel}>\n <thead>\n <tr>\n <th\n scope=\"col\"\n className=\"aegis-commit-graph__th aegis-commit-graph__th--graph\"\n aria-hidden=\"true\"\n >\n {lanes !== undefined && (\n <LaneLabels lanes={lanes} layout={layout} />\n )}\n </th>\n {columns.map((column) => (\n <th\n key={column.id}\n scope=\"col\"\n className=\"aegis-commit-graph__th\"\n >\n {column.label}\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {commits.map((commit, row) => {\n const isSelected = selected.has(commit.id);\n const firstId = `${idPrefix}-first-${String(row)}`;\n const description = rowDescription(\n idPrefix,\n row,\n layout,\n strings.mergeCommit,\n );\n return (\n <tr\n key={commit.id}\n className={\n isSelected\n ? 'aegis-commit-graph__tr aegis-commit-graph__tr--selected'\n : 'aegis-commit-graph__tr'\n }\n aria-selected={toggle === undefined ? undefined : isSelected}\n aria-describedby={description.describedBy}\n >\n <td\n className={\n row === 0\n ? 'aegis-commit-graph__td aegis-commit-graph__td--graph aegis-commit-graph__td--drawing'\n : 'aegis-commit-graph__td aegis-commit-graph__td--graph'\n }\n aria-hidden=\"true\"\n >\n {description.spans}\n {row === 0 && (\n <GraphDrawing\n commits={commits}\n layout={layout}\n selected={selected}\n />\n )}\n </td>\n {columns.map((column, index) => (\n <TableCell\n key={column.id}\n cell={commit.cells?.[column.id]}\n grow={column.grow === true}\n id={index === 0 ? firstId : undefined}\n select={\n index === 0 &&\n toggle !== undefined && (\n <span className=\"aegis-commit-graph__cell-select\">\n <Checkbox\n checked={isSelected}\n onChange={(checked) => {\n toggle(commit.id, checked);\n }}\n aria-labelledby={firstId}\n />\n </span>\n )\n }\n />\n ))}\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n}\n\nexport function CommitGraph({\n commits,\n lanes,\n columns,\n selectedIds = [],\n onSelectedIdsChange,\n maxSelected,\n ariaLabel,\n className,\n}: CommitGraphProps) {\n const narrow = useMediaQuery(NARROW_QUERY);\n const laneMinWidth = narrow ? LANE_MIN_WIDTH_NARROW : LANE_MIN_WIDTH;\n const layout = useMemo(\n () => layoutGraph(commits, lanes, laneMinWidth),\n [commits, lanes, laneMinWidth],\n );\n const toggle =\n onSelectedIdsChange === undefined\n ? undefined\n : (id: string, checked: boolean): void => {\n const next = checked\n ? [...selectedIds.filter((each) => each !== id), id]\n : selectedIds.filter((each) => each !== id);\n onSelectedIdsChange(\n maxSelected === undefined ? next : next.slice(-maxSelected),\n );\n };\n const rows: RowsProps = {\n commits,\n lanes,\n layout,\n selected: new Set(selectedIds),\n toggle,\n ariaLabel,\n };\n\n const cls = [\n 'aegis-commit-graph',\n // The list's checkboxes take a column of their own; the table's sit in its first column.\n toggle !== undefined && columns === undefined\n ? 'aegis-commit-graph--selectable'\n : '',\n className ?? '',\n ]\n .filter(Boolean)\n .join(' ');\n const rootStyle = {\n '--aegis-commit-graph-row-h': `${String(ROW_HEIGHT)}px`,\n '--aegis-commit-graph-graph-w': `${String(layout.width)}px`,\n '--aegis-commit-graph-grow-count': String(\n columns?.filter((column) => column.grow === true).length ?? 0,\n ),\n } as CSSProperties;\n\n return (\n <div className={cls} style={rootStyle}>\n {columns === undefined ? (\n <CommitList {...rows} />\n ) : (\n <CommitTable {...rows} columns={columns} />\n )}\n </div>\n );\n}\n"],"names":["ROW_HEIGHT","TRACK_WIDTH","LANE_MIN_WIDTH","LANE_MIN_WIDTH_NARROW","DOT_RADIUS","NARROW_QUERY","CUT_PART_CLASS","trackLane","laneCommits","rowOf","inLane","expected","trackOf","edges","free","index","tracks","commit","row","waiting","id","track","parent","waitingTrack","via","layoutGraph","commits","lanes","laneMinWidth","laneIds","lane","known","laneOf","dotX","laneLabel","laneBoxes","x","laneId","laneIdsOf","placed","tracksWidth","width","trackX","edge","to","links","target","drawnParents","merge","_","rowY","bend","x1","y1","x2","y2","middle","edgePath","from","fromX","toX","viaX","start","out","down","into","CutText","className","whole","children","cut","setCut","useState","jsx","Tooltip","event","text","box","rowDescription","idPrefix","layout","mergeText","mergeId","ids","jsxs","Fragment","GraphDrawing","selected","height","link","LaneLabels","CommitList","toggle","ariaLabel","strings","useStrings","useId","isSelected","titleId","description","Checkbox","checked","ref","Chip","isCellParts","cell","TableCell","grow","select","shape","part","at","content","CommitTable","columns","column","firstId","CommitGraph","selectedIds","onSelectedIdsChange","maxSelected","useMediaQuery","useMemo","next","each","rows","cls","rootStyle"],"mappings":";;;;;;;;AAwHA,MAAMA,IAAa,IACbC,IAAc,IACdC,IAAiB,KAEjBC,IAAwB,IACxBC,IAAa,GAEbC,IAAe,sBAEfC,IAAiB;AAsCvB,SAASC,EACPC,GACAC,GACAC,GAKA;AACA,QAAMC,IAAiC,CAAA,GACjCC,wBAAc,IAAA,GACdC,IAKD,CAAA,GACCC,IAAO,MAAc;AACzB,UAAMC,IAAQJ,EAAS,QAAQ,IAAI;AACnC,WAAOI,MAAU,KAAKJ,EAAS,SAASI;AAAA,EAC1C;AACA,MAAIC,IAAS;AACb,aAAW,EAAE,QAAAC,GAAQ,KAAAC,EAAA,KAASV,GAAa;AACzC,UAAMW,IAAUR,EAAS;AAAA,MAAQ,CAACS,GAAIL,MACpCK,MAAOH,EAAO,KAAK,CAACF,CAAK,IAAI,CAAA;AAAA,IAAC;AAEhC,IAAAI,EAAQ,QAAQ,CAACJ,MAAU;AACzB,MAAAJ,EAASI,CAAK,IAAI;AAAA,IACpB,CAAC;AACD,UAAMM,IAAQF,EAAQ,SAAS,IAAIA,EAAQ,CAAC,IAAIL,EAAA;AAChD,IAAAH,EAASU,CAAK,IAAI,MAClBT,EAAQ,IAAIM,GAAKG,CAAK,GACtBJ,EAAO,QACJ,OAAO,CAACK,MAAW,CAACb,EAAM,IAAIa,CAAM,K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AA,IACA,UAAU,IAAI,IAAIsC,CAAW;AAAA,IAC7B,QAAA1B;AAAA,IACA,WAAAC;AAAA,EAAA,GAGIiC,IAAM;AAAA,IACV;AAAA;AAAA,IAEAlC,MAAW,UAAasB,MAAY,SAChC,mCACA;AAAA,IACJ/C,KAAa;AAAA,EAAA,EAEZ,OAAO,OAAO,EACd,KAAK,GAAG,GACL4D,IAAY;AAAA,IAChB,8BAA8B,GAAG,OAAO/H,CAAU,CAAC;AAAA,IACnD,gCAAgC,GAAG,OAAOgF,EAAO,KAAK,CAAC;AAAA,IACvD,mCAAmC;AAAA,MACjCkC,GAAS,OAAO,CAACC,MAAWA,EAAO,SAAS,EAAI,EAAE,UAAU;AAAA,IAAA;AAAA,EAC9D;AAGF,2BACG,OAAA,EAAI,WAAWW,GAAK,OAAOC,GACzB,gBAAY,SACX,gBAAAtD,EAACkB,GAAA,EAAY,GAAGkC,GAAM,IAEtB,gBAAApD,EAACwC,MAAa,GAAGY,GAAM,SAAAX,GAAkB,GAE7C;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),e=require("react"),L=require("../../hooks/useIsomorphicLayoutEffect.cjs"),Q=require("../../hooks/useMediaQuery.cjs"),M=require("../../lib/scrollView.cjs");;/* empty css */const N=require("./selectedRowDetail.cjs"),A="(max-width: 768px)",O=e.createContext(null);function $(i,l,f,g,o){const p=o.top+g,u=i.top<p?i.top-p:Math.max(i.bottom-o.bottom,0);return Math.max(u,l+f-o.bottom)}function z({boxRef:i}){const l=e.useContext(O);return c.jsx("div",{ref:i,className:"aegis-detail-beside__inline",role:"group",children:l})}function F({columns:i,detail:l,children:f,revealKey:g,scrollContainer:o=null,className:p}){const u=Q.useMediaQuery(A),[P,x]=e.useState(!1),C=e.useRef(null),w=e.useRef(null),b=e.useRef(null),d=e.useRef(null),R=e.useRef(!1),E=e.useRef(0),y=e.useRef(g),j=e.useRef(void 0),B=e.useRef({children:f,detail:l}),a=e.useCallback(()=>{const t=d.current,s=b.current;if(t===null||s===null)return;const r=t.getBoundingClientRect(),n=w.current;if(n===null)s.style.setProperty("--aegis-detail-beside-row-height",`${String(r.height)}px`);else{const m=n.getBoundingClientRect().top;n.style.height=`${String(Math.max(r.top-m,0))}px`}},[]),h=e.useCallback(()=>{a();const t=d.current,s=b.current;if(t===null||s===null)return;const r=t.getBoundingClientRect(),n=w.current,m=$(r,n===null?r.bottom:n.getBoundingClientRect().top,s.getBoundingClientRect().height,parseFloat(getComputedStyle(s).scrollMarginTop),M.viewBoundsOf(o)),D=M.scrollerOf(o);Math.abs(m)>=1&&D.scrollBy({top:m,behavior:"instant"}),E.current=D.scrollTop},[a,o]),v=e.useCallback(()=>{j.current=y.current,R.current=!0,x(!0),queueMicrotask(()=>{h(),x(!1)})},[h]),S=e.useCallback(t=>{const s=t!==d.current;d.current=t,t===null?(R.current=!1,x(!1)):j.current!==y.current?v():(s&&(R.current=!1),a())},[a,v]),_=e.useCallback(()=>{x(!0)},[]);L.useIsomorphicLayoutEffect(()=>{const t=B.current.children!==f||B.current.detail!==l;B.current={children:f,detail:l},y.current=g,j.current!==g&&d.current!==null?v():(t&&(R.current=!1),a())}),L.useIsomorphicLayoutEffect(()=>{const t=C.current;if(t===null)return;const s=new ResizeObserver(()=>{R.current?h():a()});for(const n of u?[t]:[t,b.current])n!==null&&s.observe(n);const r=n=>{n.target instanceof Node&&d.current?.contains(n.target)&&v()};return t.addEventListener("click",r),()=>{s.disconnect(),t.removeEventListener("click",r)}},[u,a,h,v]),e.useEffect(()=>{const t=M.scrollerOf(o),s=o??window,r=()=>{Math.abs(t.scrollTop-E.current)>=1&&(R.current=!1)};return s.addEventListener("scroll",r,{passive:!0}),()=>{s.removeEventListener("scroll",r)}},[o]);const k=e.useMemo(()=>u?c.jsx(z,{boxRef:b}):null,[u]),I=e.useMemo(()=>({placeRow:S,awaitRow:_,inline:k}),[S,_,k]),q=c.jsx(N.SelectedRowDetailContext.Provider,{value:null,children:l}),T=["aegis-detail-beside",p??""].filter(Boolean).join(" ");return c.jsx(N.SelectedRowDetailContext.Provider,{value:I,children:c.jsx(O.Provider,{value:q,children:c.jsxs("div",{className:T,style:{"--aegis-detail-beside-columns":i},"aria-busy":P||void 0,children:[c.jsx("div",{ref:C,className:"aegis-detail-beside__list",children:f}),!u&&c.jsxs("div",{className:"aegis-detail-beside__side",children:[c.jsx("div",{ref:w}),c.jsx("div",{ref:b,className:"aegis-detail-beside__detail",children:q})]})]})})})}exports.DetailBeside=F;
|
|
2
2
|
//# sourceMappingURL=DetailBeside.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DetailBeside.cjs","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":"6VAgDMA,EAAe,qBAMfC,EAAgBC,EAAAA,cAAyB,IAAI,EAOnD,SAASC,EACPC,EACAC,EACAC,EACAC,EACAC,EACQ,CACR,MAAMC,EAAMD,EAAK,IAAMD,EACjBG,EACJN,EAAI,IAAMK,EAAML,EAAI,IAAMK,EAAM,KAAK,IAAIL,EAAI,OAASI,EAAK,OAAQ,CAAC,EACtE,OAAO,KAAK,IAAIE,EAAOL,EAAUC,EAASE,EAAK,MAAM,CACvD,CAGA,SAASG,EAAa,CAAE,OAAAC,GAAiD,CACvE,MAAMC,EAASC,EAAAA,WAAWb,CAAa,EACvC,OACEc,MAAC,OAAI,IAAKH,EAAQ,UAAU,8BAA8B,KAAK,QAC5D,SAAAC,CAAA,CACH,CAEJ,CAgBO,SAASG,EAAa,CAC3B,QAAAC,EACA,OAAAJ,EACA,SAAAK,EACA,gBAAAC,EAAkB,KAClB,UAAAC,CACF,EAAsB,CACpB,MAAMC,EAASC,EAAAA,cAActB,CAAY,EACnC,CAACuB,EAAMC,CAAO,EAAIC,EAAAA,SAAS,EAAK,EAChCC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAYD,EAAAA,OAAuB,IAAI,EACvCE,EAAYF,EAAAA,OAAuB,IAAI,EACvCG,EAASH,EAAAA,OAA2B,IAAI,EAExCI,EAAYJ,EAAAA,OAAO,EAAK,EACxBK,EAAgBL,EAAAA,OAAO,CAAC,EAMxBM,EAAQC,EAAAA,YAAY,IAAM,CAC9B,MAAM9B,EAAM0B,EAAO,QACbK,EAAMN,EAAU,QACtB,GAAIzB,IAAQ,MAAQ+B,IAAQ,KAC1B,OAEF,MAAMC,EA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US,CAAM,CAAA,EAEvBG,EACJ3C,MAAC4C,EAAAA,yBAAyB,SAAzB,CAAkC,MAAO,KACvC,SAAA9C,EACH,EAGI+C,EAAM,CAAC,sBAAuBxC,GAAa,EAAE,EAChD,OAAO,OAAO,EACd,KAAK,GAAG,EAEX,OACEL,EAAAA,IAAC4C,EAAAA,yBAAyB,SAAzB,CAAkC,MAAOF,EACxC,SAAA1C,EAAAA,IAACd,EAAc,SAAd,CAAuB,MAAOyD,EAC7B,SAAAG,EAAAA,KAAC,MAAA,CACC,UAAWD,EACX,MAAO,CAAE,gCAAiC3C,CAAA,EAC1C,YAAWM,GAAQ,OAEnB,SAAA,CAAAR,EAAAA,IAAC,MAAA,CAAI,IAAKW,EAAS,UAAU,4BAC1B,SAAAR,EACH,EACC,CAACG,GACAwC,EAAAA,KAAC,MAAA,CAAI,UAAU,4BACb,SAAA,CAAA9C,EAAAA,IAAC,MAAA,CAAI,IAAKa,CAAA,CAAW,QACpB,MAAA,CAAI,IAAKC,EAAW,UAAU,8BAC5B,SAAA6B,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,EAGN,CAAA,CACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"DetailBeside.cjs","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":"6VAiEMA,EAAe,qBAMfC,EAAgBC,EAAAA,cAAyB,IAAI,EAOnD,SAASC,EACPC,EACAC,EACAC,EACAC,EACAC,EACQ,CACR,MAAMC,EAAMD,EAAK,IAAMD,EACjBG,EACJN,EAAI,IAAMK,EAAML,EAAI,IAAMK,EAAM,KAAK,IAAIL,EAAI,OAASI,EAAK,OAAQ,CAAC,EACtE,OAAO,KAAK,IAAIE,EAAOL,EAAUC,EAASE,EAAK,MAAM,CACvD,CAGA,SAASG,EAAa,CAAE,OAAAC,GAAiD,CACvE,MAAMC,EAASC,EAAAA,WAAWb,CAAa,EACvC,OACEc,MAAC,OAAI,IAAKH,EAAQ,UAAU,8BAA8B,KAAK,QAC5D,SAAAC,CAAA,CACH,CAEJ,CAqBO,SAASG,EAAa,CAC3B,QAAAC,EACA,OAAAJ,EACA,SAAAK,EACA,UAAAC,EACA,gBAAAC,EAAkB,KAClB,UAAAC,CACF,EAAsB,CACpB,MAAMC,EAASC,EAAAA,cAAcvB,CAAY,EACnC,CAACwB,EAAMC,CAAO,EAAIC,EAAAA,SAAS,EAAK,EAChCC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAYD,EAAAA,OAAuB,IAAI,EACvCE,EAAYF,EAAAA,OAAuB,IAAI,EACvCG,EAASH,EAAAA,OAA2B,IAAI,EAExCI,EAAYJ,EAAAA,OAAO,EAAK,EACxBK,EAAgBL,EAAAA,OAAO,CAAC,EAExBM,EAAeN,EA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AiC,CAAA,CACH,CAAA,CAAA,CACF,CAAA,CAAA,CAAA,EAGN,CAAA,CACF,CAEJ"}
|
|
@@ -8,14 +8,31 @@ export interface DetailBesideProps {
|
|
|
8
8
|
/**
|
|
9
9
|
* The selected item's detail: one element, such as a `Panel` titled with
|
|
10
10
|
* the item's name. It is never taller than the view, so a long Panel
|
|
11
|
-
* scrolls its body.
|
|
11
|
+
* scrolls its body. Render it anew from the host's data whenever that
|
|
12
|
+
* data changes: that render tells DetailBeside the change was new data,
|
|
13
|
+
* so the page stays where it is. A detail that fetches its own data and
|
|
14
|
+
* redraws without this host rendering leaves the page following the row,
|
|
15
|
+
* and its next change of size scrolls the page.
|
|
12
16
|
*/
|
|
13
17
|
detail: ReactNode;
|
|
14
18
|
/**
|
|
15
19
|
* The list: a `TraceTree`, `FileTree`, `DataTable` or `ServiceMap`, in a
|
|
16
|
-
* Panel say. The detail follows the row it draws selected.
|
|
20
|
+
* Panel say. The detail follows the row it draws selected. Like
|
|
21
|
+
* `detail`, render it anew from the host's data whenever that data
|
|
22
|
+
* changes, so the page stays where it is on new data; a list that fetches
|
|
23
|
+
* its own data and redraws without this host rendering leaves the page
|
|
24
|
+
* following the row, and its next change of size scrolls the page.
|
|
17
25
|
*/
|
|
18
26
|
children: ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* The selection as the page's address names it, or null where the
|
|
29
|
+
* address names none and the list shows a default. It changes only by
|
|
30
|
+
* the viewer's doing: a click, a key, a link, back or forward. The page
|
|
31
|
+
* scrolls to the selected row when this changes, and on the first
|
|
32
|
+
* placement after mount; a row that comes into place for new data, such
|
|
33
|
+
* as a default the data moved, is only levelled with.
|
|
34
|
+
*/
|
|
35
|
+
revealKey: string | null;
|
|
19
36
|
/** The element that scrolls the page; omitted or null means the viewport. */
|
|
20
37
|
scrollContainer?: HTMLElement | null;
|
|
21
38
|
className?: string;
|
|
@@ -27,11 +44,16 @@ export interface DetailBesideProps {
|
|
|
27
44
|
* view's bottom, and while the page scrolls it stays in the view below
|
|
28
45
|
* the header. At 768 px and below the list draws the detail right after
|
|
29
46
|
* the selected row, the rows that follow under it; a map draws it over
|
|
30
|
-
* the map, under the node. When the page opens with a selection,
|
|
31
|
-
*
|
|
32
|
-
* once, as little as it takes to show the row and the detail
|
|
33
|
-
* again whenever the list or the detail changes size, until the
|
|
34
|
-
* scrolls
|
|
35
|
-
*
|
|
47
|
+
* the map, under the node. When the page opens with a selection,
|
|
48
|
+
* `revealKey` changes or the viewer clicks the selected row, the page
|
|
49
|
+
* scrolls at once, as little as it takes to show the row and the detail
|
|
50
|
+
* whole, and again whenever the list or the detail changes size, until the
|
|
51
|
+
* viewer scrolls or the host renders a new list or detail. Any other
|
|
52
|
+
* placement, such as new data moving the selection or the rows, levels
|
|
53
|
+
* the detail with its row by the same rule and leaves the page where it
|
|
54
|
+
* is; the browser's scroll anchoring can still move it when rows arrive
|
|
55
|
+
* above the view, unless the host sets `overflow-anchor: none` on its
|
|
56
|
+
* scroller. The wrapper is `aria-busy` while a selected row it reveals is
|
|
57
|
+
* still on its way.
|
|
36
58
|
*/
|
|
37
|
-
export declare function DetailBeside({ columns, detail, children, scrollContainer, className, }: DetailBesideProps): import("react/jsx-runtime").JSX.Element;
|
|
59
|
+
export declare function DetailBeside({ columns, detail, children, revealKey, scrollContainer, className, }: DetailBesideProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,113 +1,117 @@
|
|
|
1
|
-
import { jsx as l, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useIsomorphicLayoutEffect as
|
|
4
|
-
import { useMediaQuery as
|
|
5
|
-
import { viewBoundsOf as
|
|
1
|
+
import { jsx as l, jsxs as O } from "react/jsx-runtime";
|
|
2
|
+
import { useState as z, useRef as s, useCallback as b, useEffect as F, useMemo as P, useContext as U, createContext as W } from "react";
|
|
3
|
+
import { useIsomorphicLayoutEffect as j } from "../../hooks/useIsomorphicLayoutEffect.js";
|
|
4
|
+
import { useMediaQuery as Y } from "../../hooks/useMediaQuery.js";
|
|
5
|
+
import { viewBoundsOf as G, scrollerOf as T } from "../../lib/scrollView.js";
|
|
6
6
|
/* empty css */
|
|
7
|
-
import { SelectedRowDetailContext as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
const
|
|
11
|
-
return Math.max(
|
|
7
|
+
import { SelectedRowDetailContext as A } from "./selectedRowDetail.js";
|
|
8
|
+
const H = "(max-width: 768px)", I = W(null);
|
|
9
|
+
function J(i, c, d, m, o) {
|
|
10
|
+
const R = o.top + m, u = i.top < R ? i.top - R : Math.max(i.bottom - o.bottom, 0);
|
|
11
|
+
return Math.max(u, c + d - o.bottom);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return /* @__PURE__ */ l("div", { ref: i, className: "aegis-detail-beside__inline", role: "group", children:
|
|
13
|
+
function K({ boxRef: i }) {
|
|
14
|
+
const c = U(I);
|
|
15
|
+
return /* @__PURE__ */ l("div", { ref: i, className: "aegis-detail-beside__inline", role: "group", children: c });
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function oe({
|
|
18
18
|
columns: i,
|
|
19
|
-
detail:
|
|
20
|
-
children:
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
detail: c,
|
|
20
|
+
children: d,
|
|
21
|
+
revealKey: m,
|
|
22
|
+
scrollContainer: o = null,
|
|
23
|
+
className: R
|
|
23
24
|
}) {
|
|
24
|
-
const
|
|
25
|
-
const e =
|
|
25
|
+
const u = Y(H), [Q, h] = z(!1), E = s(null), B = s(null), g = s(null), f = s(null), p = s(!1), N = s(0), y = s(m), M = s(void 0), _ = s({ children: d, detail: c }), a = b(() => {
|
|
26
|
+
const e = f.current, t = g.current;
|
|
26
27
|
if (e === null || t === null)
|
|
27
28
|
return;
|
|
28
|
-
const
|
|
29
|
+
const r = e.getBoundingClientRect(), n = B.current;
|
|
29
30
|
if (n === null)
|
|
30
31
|
t.style.setProperty(
|
|
31
32
|
"--aegis-detail-beside-row-height",
|
|
32
|
-
`${String(
|
|
33
|
+
`${String(r.height)}px`
|
|
33
34
|
);
|
|
34
35
|
else {
|
|
35
|
-
const
|
|
36
|
-
n.style.height = `${String(Math.max(
|
|
36
|
+
const w = n.getBoundingClientRect().top;
|
|
37
|
+
n.style.height = `${String(Math.max(r.top - w, 0))}px`;
|
|
37
38
|
}
|
|
38
|
-
}, []),
|
|
39
|
-
|
|
40
|
-
const e =
|
|
39
|
+
}, []), x = b(() => {
|
|
40
|
+
a();
|
|
41
|
+
const e = f.current, t = g.current;
|
|
41
42
|
if (e === null || t === null)
|
|
42
43
|
return;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
n === null ?
|
|
44
|
+
const r = e.getBoundingClientRect(), n = B.current, w = J(
|
|
45
|
+
r,
|
|
46
|
+
n === null ? r.bottom : n.getBoundingClientRect().top,
|
|
46
47
|
t.getBoundingClientRect().height,
|
|
47
48
|
parseFloat(getComputedStyle(t).scrollMarginTop),
|
|
48
|
-
|
|
49
|
-
),
|
|
50
|
-
Math.abs(
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
G(o)
|
|
50
|
+
), k = T(o);
|
|
51
|
+
Math.abs(w) >= 1 && k.scrollBy({ top: w, behavior: "instant" }), N.current = k.scrollTop;
|
|
52
|
+
}, [a, o]), v = b(() => {
|
|
53
|
+
M.current = y.current, p.current = !0, h(!0), queueMicrotask(() => {
|
|
54
|
+
x(), h(!1);
|
|
54
55
|
});
|
|
55
|
-
}, [
|
|
56
|
+
}, [x]), C = b(
|
|
56
57
|
(e) => {
|
|
57
|
-
const t = e !==
|
|
58
|
-
|
|
58
|
+
const t = e !== f.current;
|
|
59
|
+
f.current = e, e === null ? (p.current = !1, h(!1)) : M.current !== y.current ? v() : (t && (p.current = !1), a());
|
|
59
60
|
},
|
|
60
|
-
[
|
|
61
|
-
),
|
|
62
|
-
|
|
61
|
+
[a, v]
|
|
62
|
+
), S = b(() => {
|
|
63
|
+
h(!0);
|
|
63
64
|
}, []);
|
|
64
|
-
|
|
65
|
-
const e =
|
|
65
|
+
j(() => {
|
|
66
|
+
const e = _.current.children !== d || _.current.detail !== c;
|
|
67
|
+
_.current = { children: d, detail: c }, y.current = m, M.current !== m && f.current !== null ? v() : (e && (p.current = !1), a());
|
|
68
|
+
}), j(() => {
|
|
69
|
+
const e = E.current;
|
|
66
70
|
if (e === null)
|
|
67
71
|
return;
|
|
68
72
|
const t = new ResizeObserver(() => {
|
|
69
|
-
|
|
73
|
+
p.current ? x() : a();
|
|
70
74
|
});
|
|
71
|
-
for (const n of
|
|
75
|
+
for (const n of u ? [e] : [e, g.current])
|
|
72
76
|
n !== null && t.observe(n);
|
|
73
|
-
const
|
|
74
|
-
n.target instanceof Node &&
|
|
77
|
+
const r = (n) => {
|
|
78
|
+
n.target instanceof Node && f.current?.contains(n.target) && v();
|
|
75
79
|
};
|
|
76
|
-
return e.addEventListener("click",
|
|
77
|
-
t.disconnect(), e.removeEventListener("click",
|
|
80
|
+
return e.addEventListener("click", r), () => {
|
|
81
|
+
t.disconnect(), e.removeEventListener("click", r);
|
|
78
82
|
};
|
|
79
|
-
}, [
|
|
80
|
-
const e =
|
|
81
|
-
Math.abs(e.scrollTop -
|
|
83
|
+
}, [u, a, x, v]), F(() => {
|
|
84
|
+
const e = T(o), t = o ?? window, r = () => {
|
|
85
|
+
Math.abs(e.scrollTop - N.current) >= 1 && (p.current = !1);
|
|
82
86
|
};
|
|
83
|
-
return t.addEventListener("scroll",
|
|
84
|
-
t.removeEventListener("scroll",
|
|
87
|
+
return t.addEventListener("scroll", r, { passive: !0 }), () => {
|
|
88
|
+
t.removeEventListener("scroll", r);
|
|
85
89
|
};
|
|
86
|
-
}, [
|
|
87
|
-
const
|
|
88
|
-
() =>
|
|
89
|
-
[
|
|
90
|
-
),
|
|
91
|
-
() => ({ placeRow:
|
|
92
|
-
[
|
|
93
|
-
),
|
|
94
|
-
return /* @__PURE__ */ l(
|
|
90
|
+
}, [o]);
|
|
91
|
+
const D = P(
|
|
92
|
+
() => u ? /* @__PURE__ */ l(K, { boxRef: g }) : null,
|
|
93
|
+
[u]
|
|
94
|
+
), $ = P(
|
|
95
|
+
() => ({ placeRow: C, awaitRow: S, inline: D }),
|
|
96
|
+
[C, S, D]
|
|
97
|
+
), L = /* @__PURE__ */ l(A.Provider, { value: null, children: c }), q = ["aegis-detail-beside", R ?? ""].filter(Boolean).join(" ");
|
|
98
|
+
return /* @__PURE__ */ l(A.Provider, { value: $, children: /* @__PURE__ */ l(I.Provider, { value: L, children: /* @__PURE__ */ O(
|
|
95
99
|
"div",
|
|
96
100
|
{
|
|
97
|
-
className:
|
|
101
|
+
className: q,
|
|
98
102
|
style: { "--aegis-detail-beside-columns": i },
|
|
99
|
-
"aria-busy":
|
|
103
|
+
"aria-busy": Q || void 0,
|
|
100
104
|
children: [
|
|
101
|
-
/* @__PURE__ */ l("div", { ref:
|
|
102
|
-
!
|
|
103
|
-
/* @__PURE__ */ l("div", { ref:
|
|
104
|
-
/* @__PURE__ */ l("div", { ref:
|
|
105
|
+
/* @__PURE__ */ l("div", { ref: E, className: "aegis-detail-beside__list", children: d }),
|
|
106
|
+
!u && /* @__PURE__ */ O("div", { className: "aegis-detail-beside__side", children: [
|
|
107
|
+
/* @__PURE__ */ l("div", { ref: B }),
|
|
108
|
+
/* @__PURE__ */ l("div", { ref: g, className: "aegis-detail-beside__detail", children: L })
|
|
105
109
|
] })
|
|
106
110
|
]
|
|
107
111
|
}
|
|
108
112
|
) }) });
|
|
109
113
|
}
|
|
110
114
|
export {
|
|
111
|
-
|
|
115
|
+
oe as DetailBeside
|
|
112
116
|
};
|
|
113
117
|
//# sourceMappingURL=DetailBeside.js.map
|