@ctrl/react-orgchart 1.3.0 → 1.4.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/README.md +3 -3
- package/dist/index.d.mts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +463 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +462 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +69 -53
- package/.circleci/config.yml +0 -46
- package/.editorconfig +0 -13
- package/.eslintignore +0 -5
- package/.eslintrc +0 -16
- package/.nvmrc +0 -1
- package/.prettierrc +0 -8
- package/demo/App.tsx +0 -20
- package/demo/assets/avatar-personnel.svg +0 -1
- package/demo/index.css +0 -28
- package/demo/index.html +0 -15
- package/demo/index.tsx +0 -19
- package/demo/testdata.tsx +0 -1231
- package/snowpack.config.js +0 -14
- package/src/chart/components/iconLink.jsx +0 -46
- package/src/chart/config.ts +0 -83
- package/src/chart/index.js +0 -172
- package/src/chart/onClick.js +0 -37
- package/src/chart/render.js +0 -253
- package/src/chart/renderLines.js +0 -119
- package/src/index.ts +0 -1
- package/src/orgChart.tsx +0 -66
- package/src/utils/collapse.js +0 -7
- package/src/utils/helpers.js +0 -25
- package/src/utils/index.js +0 -3
- package/src/utils/wrapText.js +0 -73
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -23
- package/vercel.json +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["helpers.getCursorForNode","getName","helpers.getName","helpers.customOnClick","getTitle","helpers.getTitle","getCount","helpers.getCount","helpers.wrapText","defaultChartConfig","config","zoom","zoomer","defaultConfig"],"sources":["../src/chart/config.ts","../src/utils/collapse.ts","../src/utils/wrapText.ts","../src/utils/helpers.ts","../src/chart/components/iconLink.ts","../src/chart/onClick.ts","../src/chart/renderLines.ts","../src/chart/render.ts","../src/chart/index.ts","../src/orgChart.tsx"],"sourcesContent":["const animationDuration = 350;\nconst shouldResize = true;\n\n// Nodes\nconst nodeWidth = 140;\nconst nodeHeight = 190;\nconst nodeSpacing = 12;\nconst nodePaddingX = 16;\nconst nodePaddingY = 16;\nconst avatarWidth = 48;\nconst nodeBorderRadius = 4;\n\n// Lines\n/* Height of the line for child nodes */\nconst lineDepthY = 120;\n\n// Colors\nconst backgroundColor = '#fff';\n// Theme.borderlight\nconst borderColor = '#E7E1EC';\n// Theme.gray800\nconst nameColor = '#302839';\n// Theme.gray600\nconst titleColor = '#645574';\nconst reportsColor = '#92A0AD';\n\nexport interface Config {\n animationDuration: number;\n nodeWidth: number;\n nodeHeight: number;\n nodeSpacing: number;\n nodePaddingX: number;\n nodePaddingY: number;\n nodeBorderRadius: number;\n avatarWidth: number;\n lineDepthY: number;\n backgroundColor: string;\n borderColor: string;\n nameColor: string;\n titleColor: string;\n reportsColor: string;\n shouldResize: boolean;\n nameFontSize: number;\n titleFontSize: number;\n titleYTopDistance: number;\n countFontSize: number;\n countYTopDistance: number;\n maxNameWordLength: number;\n maxTitleWordLength: number;\n maxCountWordLength: number;\n onEntityLinkClick?: (data: unknown, event: Event) => boolean | void;\n onNameClick?: (data: unknown, event: Event) => boolean | void;\n onCountClick?: (data: unknown, event: Event) => boolean | void;\n getName?: (data: unknown) => string;\n getTitle?: (data: unknown) => string;\n getCount?: (data: unknown) => string;\n}\n\nexport const config: Config = {\n animationDuration,\n nodeWidth,\n nodeHeight,\n nodeSpacing,\n nodePaddingX,\n nodePaddingY,\n nodeBorderRadius,\n avatarWidth,\n lineDepthY,\n backgroundColor,\n borderColor,\n nameColor,\n titleColor,\n reportsColor,\n shouldResize,\n nameFontSize: 14,\n titleFontSize: 13,\n titleYTopDistance: 25,\n countFontSize: 14,\n countYTopDistance: 72,\n maxNameWordLength: 16,\n maxTitleWordLength: 17,\n maxCountWordLength: 17,\n};\n","import type { ChartNode } from '../chart/types';\n\nexport function collapse(d: ChartNode): void {\n // Check if this node has children\n if (d.children) {\n d._children = d.children;\n d.children = undefined;\n }\n}\n","import { select, type Selection } from 'd3-selection';\n\nconst getTruncatedText = (text: string, maxWordLength: number): string => {\n if (text.length <= maxWordLength) {\n return text;\n }\n\n if (maxWordLength <= 3) {\n return '.'.repeat(maxWordLength);\n }\n\n return `${text.slice(0, maxWordLength - 3)}...`;\n};\n\n// One way of achieving text-wrapping capability in SVG\n// Text is broken down to words, each word is added to a line and then the lines width is checked\n// If the line width is less than the max we move to the next word, if more we add new line etc\n// until the max number of lines is reached.\nexport function wrapText<Datum>(\n text: Selection<SVGTextElement, Datum, SVGGElement, unknown>,\n maxLineWidth: number,\n maxNumberOfLines = 3,\n maxWordLength = 17,\n): void {\n let editedClass = '';\n\n text.each(function eachTextNode() {\n const textSelection = select(this);\n const x = textSelection.attr('x');\n const y = textSelection.attr('y');\n const dy = Number.parseFloat(textSelection.attr('dy') ?? '0');\n const lineHeight = 1.1;\n const words = textSelection.text().split(/\\s+/).reverse();\n\n let lineNumber = 0;\n let curLineWidth = 0;\n let word = '';\n let line: string[] = [];\n let tspan = textSelection\n .text(null)\n .append('tspan')\n .style('text-anchor', 'middle')\n .attr('x', x)\n .attr('y', y)\n .attr('dy', `${dy}em`);\n\n while (lineNumber < maxNumberOfLines && words.length > 0) {\n const nextWord = words.pop();\n if (!nextWord) {\n break;\n }\n\n word = nextWord;\n line.push(word);\n tspan.text(line.join(' '));\n\n curLineWidth = tspan.node()?.getComputedTextLength() ?? 0;\n\n if (curLineWidth > maxLineWidth) {\n if (lineNumber + 1 === maxNumberOfLines) {\n tspan.text(getTruncatedText(line.join(' '), maxWordLength));\n break;\n } else {\n line.pop();\n tspan.text(line.join(' '));\n line = [word];\n tspan = textSelection\n .append('tspan')\n .style('text-anchor', 'middle')\n .attr('x', x)\n .attr('y', y)\n .attr('dy', `${++lineNumber * lineHeight + dy}em`)\n .text(getTruncatedText(word, maxWordLength));\n }\n\n if (word.length > maxWordLength) {\n break;\n }\n }\n }\n\n if (!editedClass) {\n editedClass = (textSelection.attr('class') ?? '').replace(' unedited', '');\n }\n\n textSelection.attr('class', editedClass);\n });\n}\n","import type { ChartConfig, ChartNode } from '../chart/types';\n\ntype CustomClickHandler = ((data: unknown, event: Event) => boolean | void) | undefined;\ntype OnClickFactory = (config: ChartConfig) => (event: Event, datum: ChartNode) => void;\n\nexport const getName = (data: ChartNode): string => data.data.entity?.name ?? '';\n\nexport const getTitle = (data: ChartNode): string => data.data.entity?.title ?? '';\n\nexport const getCount = (data: ChartNode): string => {\n const visibleChildren = data.children?.length ?? 0;\n const collapsedChildren = data._children?.length ?? 0;\n const children = visibleChildren > 0 ? visibleChildren : collapsedChildren;\n\n if (!children) {\n return '';\n }\n\n return `Team (${children})`;\n};\n\nexport const getCursorForNode = (data: ChartNode): string =>\n data.children || data._children || data.data.children || data.data._children\n ? 'pointer'\n : 'default';\n\nexport const customOnClick =\n (fn: CustomClickHandler, onClick: OnClickFactory, config: ChartConfig) =>\n (event: Event, data: ChartNode): void => {\n if (typeof fn === 'function') {\n if (fn(data, event)) {\n onClick(config);\n } else {\n event.stopPropagation();\n }\n }\n };\n","import type { Selection } from 'd3-selection';\n\nimport type { ChartNode } from '../types';\n\ntype EntityLinkSelection = Selection<HTMLAnchorElement, ChartNode, SVGGElement, unknown>;\n\nexport const iconLink = ({\n svg,\n x = 5,\n y = 5,\n}: {\n svg: EntityLinkSelection;\n x?: number;\n y?: number;\n}): void => {\n const container = svg\n .append('g')\n .attr('stroke', 'none')\n .attr('fill', 'none')\n .style('cursor', 'pointer')\n .append('g');\n\n const icon = container\n .append('g')\n .attr('id', 'icon')\n .attr('fill', '#9585A3')\n .attr('transform', `translate(${x}, ${y})`);\n\n const arrow = icon\n .append('g')\n .attr('id', 'arrow')\n .attr(\n 'transform',\n 'translate(7.000000, 7.000000) scale(-1, 1) translate(-7.000000, -7.000000)',\n );\n\n arrow\n .append('path')\n .attr(\n 'd',\n 'M3.41421356,2 L8.70710678,7.29289322 C9.09763107,7.68341751 9.09763107,8.31658249 8.70710678,8.70710678 C8.31658249,9.09763107 7.68341751,9.09763107 7.29289322,8.70710678 L2,3.41421356 L2,7 C2,7.55228475 1.55228475,8 1,8 C0.44771525,8 0,7.55228475 0,7 L0,1.49100518 C0,0.675320548 0.667758414,0 1.49100518,0 L7,0 C7.55228475,0 8,0.44771525 8,1 C8,1.55228475 7.55228475,2 7,2 L3.41421356,2 Z',\n );\n\n arrow\n .append('path')\n // .attr('opacity', 0.7)\n .attr(\n 'd',\n 'M12,2 L12,12 L2,12 L2,11 C2,10.4477153 1.55228475,10 1,10 C0.44771525,10 0,10.4477153 0,11 L0,12.4953156 C0,13.3242086 0.674596865,14 1.50034732,14 L12.4996527,14 C13.3281027,14 14,13.3234765 14,12.4996527 L14,1.50034732 C14,0.669321781 13.3358906,0 12.4953156,0 L11,0 C10.4477153,0 10,0.44771525 10,1 C10,1.55228475 10.4477153,2 11,2 L12,2 Z',\n );\n\n icon\n .append('rect')\n .attr('id', 'bounds')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', 24)\n .attr('height', 24)\n .attr('fill', 'transparent');\n};\n","import type { ChartConfig, ChartNode } from './types';\n\nexport function onClick(config: ChartConfig): (event: Event, datum: ChartNode) => void {\n const { render } = config;\n\n return (event: Event, datum: ChartNode): void => {\n if (event.defaultPrevented) {\n return;\n }\n\n const target = event.target;\n const link = target instanceof Element ? target.closest('a') : null;\n if (link instanceof HTMLAnchorElement && link.href) {\n return;\n }\n\n if (!datum.children && !datum._children) {\n return;\n }\n\n if (datum.children) {\n // Collapse the children\n config.callerNode = datum;\n datum._children = datum.children;\n datum.children = undefined;\n } else {\n // Expand the children\n config.callerNode = undefined;\n datum.children = datum._children;\n datum._children = undefined;\n }\n\n // Pass in the clicked datum as the sourceNode which\n // tells the child nodes where to animate in from\n render({\n ...config,\n sourceNode: datum,\n });\n };\n}\n","import { curveLinear, line } from 'd3-shape';\n\nimport type { ChartConfig, ChartLink } from './types';\n\nconst margin = 10;\n\ntype LinePoint = { x: number; y: number };\n\ntype RenderLinesConfig = Pick<\n ChartConfig,\n 'svg' | 'links' | 'nodeWidth' | 'nodeHeight' | 'borderColor' | 'sourceNode' | 'animationDuration'\n>;\n\nexport function renderLines(config: RenderLinesConfig): void {\n const { svg, links, nodeWidth, nodeHeight, borderColor, sourceNode, animationDuration } = config;\n\n // Select all the links to render the lines\n const link = svg\n .selectAll<SVGPathElement, ChartLink>('path.link')\n .data(links, ({ source, target }) => {\n return `${source.data.id ?? ''}-${target.data.id ?? ''}`;\n });\n\n // Define the angled line function\n const angle = line<LinePoint>()\n .x(point => point.x)\n .y(point => point.y)\n .curve(curveLinear);\n const halfNodeWidth = nodeWidth / 2;\n\n // Enter new links at the parent's previous position.\n const linkEnter = link\n .enter()\n .insert('path', 'g')\n .attr('class', 'link')\n .attr('fill', 'none')\n .attr('stroke', borderColor)\n .attr('stroke-opacity', 1)\n .attr('stroke-width', 1.25)\n .attr('d', linkDatum => {\n const linePoints: LinePoint[] = [\n {\n x: linkDatum.source.x + halfNodeWidth,\n y: linkDatum.source.y + margin,\n },\n {\n x: linkDatum.source.x + halfNodeWidth,\n y: linkDatum.source.y + margin,\n },\n {\n x: linkDatum.source.x + halfNodeWidth,\n y: linkDatum.source.y + margin,\n },\n {\n x: linkDatum.source.x + halfNodeWidth,\n y: linkDatum.source.y + margin,\n },\n ];\n\n return angle(linePoints);\n });\n\n const linkUpdate = linkEnter.merge(link);\n\n // Transition links to their new position.\n linkUpdate\n .transition()\n .duration(animationDuration)\n .attr('d', linkDatum => {\n const linePoints: LinePoint[] = [\n {\n x: linkDatum.source.x + halfNodeWidth,\n y: linkDatum.source.y + nodeHeight,\n },\n {\n x: linkDatum.source.x + halfNodeWidth,\n y: linkDatum.target.y - margin,\n },\n {\n x: linkDatum.target.x + halfNodeWidth,\n y: linkDatum.target.y - margin,\n },\n {\n x: linkDatum.target.x + halfNodeWidth,\n y: linkDatum.target.y,\n },\n ];\n\n return angle(linePoints);\n });\n\n // Animate existing links to the parent's new position\n link\n .exit()\n .transition()\n .duration(animationDuration)\n .attr('d', () => {\n const lineNodeX = sourceNode?.x ?? 0;\n const lineNodeY = sourceNode?.y ?? 0;\n const linePoints: LinePoint[] = [\n {\n x: lineNodeX + halfNodeWidth,\n y: lineNodeY + nodeHeight + 2,\n },\n {\n x: lineNodeX + halfNodeWidth,\n y: lineNodeY + nodeHeight + 2,\n },\n {\n x: lineNodeX + halfNodeWidth,\n y: lineNodeY + nodeHeight + 2,\n },\n {\n x: lineNodeX + halfNodeWidth,\n y: lineNodeY + nodeHeight + 2,\n },\n ];\n\n return angle(linePoints);\n })\n .remove();\n}\n","import * as helpers from '../utils/index';\n\nimport { iconLink } from './components/iconLink';\nimport { onClick } from './onClick';\nimport { renderLines } from './renderLines';\nimport type { ChartConfig, ChartLink, ChartNode } from './types';\n\nconst CHART_NODE_CLASS = 'org-chart-node';\nconst ENTITY_LINK_CLASS = 'org-chart-entity-link';\nconst ENTITY_NAME_CLASS = 'org-chart-entity-name';\nconst ENTITY_TITLE_CLASS = 'org-chart-entity-title';\nconst COUNTS_CLASS = 'org-chart-counts';\n\nexport function render(config: ChartConfig): void {\n const {\n svg,\n tree,\n animationDuration,\n nodeWidth,\n nodeHeight,\n nodePaddingY,\n nodeBorderRadius,\n backgroundColor,\n nameColor,\n titleColor,\n reportsColor,\n borderColor,\n avatarWidth,\n lineDepthY,\n sourceNode,\n onEntityLinkClick,\n nameFontSize = 14,\n titleFontSize = 13,\n titleYTopDistance = 25,\n countFontSize = 14,\n countYTopDistance = 72,\n maxNameWordLength = 16,\n maxTitleWordLength = 17,\n maxCountWordLength = 17,\n getName,\n getTitle,\n getCount,\n onNameClick,\n onCountClick,\n treeMap,\n } = config;\n\n // Compute the new tree layout.\n const data = treeMap(tree);\n const nodes = data.descendants() as ChartNode[];\n const links = data.links() as ChartLink[];\n\n config.links = links;\n config.nodes = nodes;\n\n // Normalize for fixed-depth.\n nodes.forEach(node => {\n node.y = node.depth * lineDepthY;\n });\n\n // Update the nodes\n const node = svg\n .selectAll<SVGGElement, ChartNode>(`g.${CHART_NODE_CLASS}`)\n .data(nodes, nodeDatum => nodeDatum.data.id ?? '');\n const parentNode = sourceNode ?? nodes[0];\n\n // Enter new nodes at the parent's previous position.\n const nodeEnter = node\n .enter()\n .append('g')\n .attr('class', CHART_NODE_CLASS)\n .attr('transform', () => {\n return `translate(${parentNode.x0 ?? parentNode.x}, ${parentNode.y0 ?? parentNode.y})`;\n })\n .on('click', onClick(config));\n\n // Entity Card Shadow\n nodeEnter\n .append('rect')\n .attr('width', nodeWidth)\n .attr('height', nodeHeight)\n .attr('fill', backgroundColor)\n .attr('stroke', borderColor)\n .attr('rx', nodeBorderRadius)\n .attr('ry', nodeBorderRadius)\n .attr('fill-opacity', 0.05)\n .attr('stroke-opacity', 0.025)\n .attr('filter', 'url(#boxShadow)');\n\n // Entity Card Container\n nodeEnter\n .append('rect')\n .attr('width', nodeWidth)\n .attr('height', nodeHeight)\n .attr('id', nodeDatum => `${nodeDatum.data.id ?? ''}`)\n .attr('fill', backgroundColor)\n .attr('stroke', borderColor)\n .attr('rx', nodeBorderRadius)\n .attr('ry', nodeBorderRadius)\n .style('cursor', helpers.getCursorForNode);\n\n const namePos = {\n x: nodeWidth / 2,\n y: nodePaddingY * 1.8 + avatarWidth,\n };\n\n const avatarPos = {\n x: nodeWidth / 2 - avatarWidth / 2,\n y: nodePaddingY / 2,\n };\n\n // Entity's Name\n nodeEnter\n .append('text')\n .attr('class', `${ENTITY_NAME_CLASS} unedited`)\n .attr('x', namePos.x)\n .attr('y', namePos.y)\n .attr('dy', '.3em')\n .style('cursor', 'pointer')\n .style('fill', nameColor)\n .style('font-size', nameFontSize)\n .text(nodeDatum =>\n typeof getName === 'function' ? getName(nodeDatum) : helpers.getName(nodeDatum),\n )\n .on('click', helpers.customOnClick(onNameClick, onClick, config));\n\n // Title\n nodeEnter\n .append('text')\n .attr('class', `${ENTITY_TITLE_CLASS} unedited`)\n .attr('x', nodeWidth / 2)\n .attr('y', namePos.y + nodePaddingY + titleYTopDistance)\n .attr('dy', '0.1em')\n .style('font-size', titleFontSize)\n .style('cursor', 'pointer')\n .style('fill', titleColor)\n .text(nodeDatum =>\n typeof getTitle === 'function' ? getTitle(nodeDatum) : helpers.getTitle(nodeDatum),\n );\n\n // Count\n nodeEnter\n .append('text')\n .attr('class', `${COUNTS_CLASS} unedited`)\n .attr('x', nodeWidth / 2)\n .attr('y', namePos.y + nodePaddingY + countYTopDistance)\n .attr('dy', '.9em')\n .style('font-size', countFontSize)\n .style('font-weight', 400)\n .style('cursor', 'pointer')\n .style('fill', reportsColor)\n .text(nodeDatum =>\n typeof getCount === 'function' ? getCount(nodeDatum) : helpers.getCount(nodeDatum),\n )\n .on('click', helpers.customOnClick(onCountClick, onClick, config));\n\n // Entity's Avatar\n nodeEnter\n .append('image')\n .attr('id', nodeDatum => `image-${nodeDatum.data.id ?? ''}`)\n .attr('width', avatarWidth)\n .attr('height', avatarWidth)\n .attr('x', avatarPos.x)\n .attr('y', avatarPos.y)\n .attr('stroke', borderColor)\n .attr('src', nodeDatum => nodeDatum.data.entity?.avatar ?? '')\n .attr('href', nodeDatum => nodeDatum.data.entity?.avatar ?? '')\n .attr('clip-path', 'url(#avatarClip)');\n\n // Entity's Link\n const nodeLink = nodeEnter\n .append('a')\n .attr('class', ENTITY_LINK_CLASS)\n .attr('display', nodeDatum => (nodeDatum.data.entity?.link ? '' : 'none'))\n .attr('xlink:href', nodeDatum => nodeDatum.data.entity?.link ?? '')\n .on('click', helpers.customOnClick(onEntityLinkClick, onClick, config));\n\n iconLink({\n svg: nodeLink,\n x: nodeWidth - 20,\n y: 8,\n });\n\n const nodeUpdate = nodeEnter.merge(node);\n\n // Transition nodes to their new position.\n nodeUpdate\n .transition()\n .duration(animationDuration)\n .attr('transform', nodeDatum => {\n return `translate(${nodeDatum.x},${nodeDatum.y})`;\n });\n\n nodeUpdate.select('rect.box').attr('fill', backgroundColor).attr('stroke', borderColor);\n\n // Transition exiting nodes to the parent's new position.\n node\n .exit()\n .transition()\n .duration(animationDuration)\n .attr('transform', () => `translate(${parentNode.x},${parentNode.y})`)\n .remove();\n\n // Update the links\n svg\n .selectAll<SVGPathElement, ChartLink>('path.link')\n .data(links, linkDatum => linkDatum.target.data.id ?? '');\n\n [\n { cls: ENTITY_NAME_CLASS, max: maxNameWordLength },\n { cls: ENTITY_TITLE_CLASS, max: maxTitleWordLength },\n { cls: COUNTS_CLASS, max: maxCountWordLength },\n ].forEach(({ cls, max }) => {\n svg.selectAll<SVGTextElement, ChartNode>(`text.unedited.${cls}`).call(\n helpers.wrapText,\n nodeWidth - 12, // Adjust with some padding\n // Name should wrap at 3 lines max\n cls === ENTITY_NAME_CLASS ? 3 : 2,\n max,\n );\n });\n\n // Add tooltips\n svg\n .selectAll<SVGTextElement, ChartNode>(`text.${ENTITY_NAME_CLASS}`)\n .append('svg:title')\n .text(nodeDatum => (getName ? getName(nodeDatum) : helpers.getName(nodeDatum)));\n svg\n .selectAll<SVGTextElement, ChartNode>(`text.${ENTITY_TITLE_CLASS}`)\n .append('svg:title')\n .text(nodeDatum => (getTitle ? getTitle(nodeDatum) : helpers.getTitle(nodeDatum)));\n svg\n .selectAll<SVGTextElement, ChartNode>(`text.${COUNTS_CLASS}`)\n .append('svg:title')\n .text(nodeDatum => (getCount ? getCount(nodeDatum) : helpers.getCount(nodeDatum)));\n\n // Render lines connecting nodes\n renderLines(config);\n\n // Stash the old positions for transition.\n nodes.forEach(nodeDatum => {\n nodeDatum.x0 = nodeDatum.x;\n nodeDatum.y0 = nodeDatum.y;\n });\n\n let nodeLeftX = -70;\n let nodeRightX = 70;\n let nodeY = 200;\n nodes.forEach(nodeDatum => {\n nodeLeftX = nodeDatum.x < nodeLeftX ? nodeDatum.x : nodeLeftX;\n nodeRightX = nodeDatum.x > nodeRightX ? nodeDatum.x : nodeRightX;\n nodeY = nodeDatum.y > nodeY ? nodeDatum.y : nodeY;\n });\n\n config.nodeRightX = nodeRightX;\n config.nodeY = nodeY;\n config.nodeLeftX = nodeLeftX * -1;\n}\n","import { hierarchy, tree } from 'd3-hierarchy';\nimport { select } from 'd3-selection';\nimport { zoom as zoomer, zoomIdentity, type D3ZoomEvent } from 'd3-zoom';\n\nimport type { TreeItem } from '../types';\nimport { collapse } from '../utils/index';\n\nimport { config as defaultChartConfig, type Config } from './config';\nimport { render } from './render';\nimport type { ChartConfig, ChartNode } from './types';\n\nexport type OrgChartInitOptions = Partial<Config> & {\n id: string;\n elem: HTMLElement | null;\n data: TreeItem | TreeItem[];\n disableCanvasMouseWheelZoom?: boolean;\n disableCanvasMouseMove?: boolean;\n};\n\nexport function initializeOrgChart(options: OrgChartInitOptions): () => void {\n if (!options.id) {\n throw new Error('missing id for svg root');\n }\n\n const mergedConfig = {\n ...defaultChartConfig,\n ...options,\n };\n\n const { elem, nodeWidth, nodeHeight, nodeSpacing, shouldResize } = mergedConfig;\n const treeData = mergedConfig.data as TreeItem;\n\n // Calculate how many pixel nodes to be spaced based on the\n // type of line that needs to be rendered\n const lineDepthY = nodeHeight + 40;\n\n if (!elem) {\n throw new Error('No root elem');\n }\n\n // Reset in case there's pre-existing DOM\n elem.innerHTML = '';\n const elemWidth = elem.offsetWidth;\n const elemHeight = elem.offsetHeight;\n\n // Setup the d3 tree layout\n const treeRoot = hierarchy(treeData, d => d.children ?? undefined);\n const treeMap = tree<TreeItem>().nodeSize([nodeWidth + nodeSpacing, nodeHeight + nodeSpacing]);\n\n // Collapse tree on load\n treeMap(treeRoot)\n .descendants()\n .slice(1)\n .forEach(node => collapse(node as ChartNode));\n\n // Calculate width of a node with expanded children\n // const childrenWidth = parseInt((treeData.children.length * nodeWidth) / 2)\n\n // <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" x=\"0px\" y=\"0px\" xml:space=\"preserve\" viewBox=\"0 0 193 260\" enable-background=\" new 0 0 193 260\" height=\"260\" width=\"193\"\n // Add svg root for d3\n const svgroot = select(elem)\n .append('svg')\n .attr('id', 'svg')\n .attr('xmlns', 'http://www.w3.org/2000/svg')\n .attr('xmlns:xlink', 'http://www.w3.org/1999/xlink')\n .attr('x', '0px')\n .attr('y', '0px')\n .attr('xml:space', 'preserve')\n .attr('viewBox', `0 0 ${elemWidth} ${elemHeight}`)\n .attr('enable-background', ` new 0 0 ${elemWidth} ${elemHeight}`)\n .attr('width', elemWidth)\n .attr('height', elemHeight);\n\n // Graph center point\n const centerPoint = elemWidth / 2 - nodeWidth / 2 + 15;\n\n // Add our base svg group to transform when a user zooms/pans\n const svg = svgroot.append('g');\n\n const config: ChartConfig = {\n ...mergedConfig,\n data: treeData,\n lineDepthY,\n treeData,\n tree: treeRoot,\n treeMap,\n svg,\n svgroot,\n render,\n links: [],\n nodes: [],\n elemWidth,\n elemHeight,\n };\n\n // Defined zoom behavior\n const zoom = zoomer<SVGSVGElement, unknown>()\n .scaleExtent([0.1, 1.5])\n .duration(50)\n .on('zoom', (zoomEvent: D3ZoomEvent<SVGSVGElement, unknown>) => {\n svg.attr('transform', zoomEvent.transform.toString());\n });\n\n svgroot.call(zoom.transform, zoomIdentity.translate(centerPoint, 48).scale(0.8));\n\n const zoomedRoot = svgroot.call(zoom);\n\n // Disable the Mouse Wheel Zooming\n if (config.disableCanvasMouseWheelZoom) {\n zoomedRoot.on('wheel.zoom', null);\n }\n\n // Disable the Mouse Wheel Canvas Content Moving\n if (config.disableCanvasMouseMove) {\n zoomedRoot\n .on('mousedown.zoom', null)\n .on('touchstart.zoom', null)\n .on('touchmove.zoom', null)\n .on('touchend.zoom', null);\n }\n\n // Add avatar clip path\n const defs = svgroot.append('svg:defs');\n defs\n .append('clipPath')\n .attr('id', 'avatarClip')\n .append('circle')\n .attr('cx', 70)\n .attr('cy', 32)\n .attr('r', 24);\n\n // Add boxshadow\n const filter = svgroot\n .append('svg:defs')\n .append('svg:filter')\n .attr('id', 'boxShadow')\n .attr('height', '150%')\n .attr('width', '150%');\n\n filter\n .append('svg:feGaussianBlur')\n .attr('in', 'SourceAlpha')\n .attr('stdDeviation', 1) // blur amount\n .attr('result', 'blurOut');\n\n filter\n .append('svg:feOffset')\n .attr('in', 'blurOut')\n .attr('dx', 0)\n .attr('dy', 2)\n .attr('result', 'offsetOut');\n\n const feMerge = filter.append('feMerge');\n feMerge.append('feMergeNode').attr('in', 'offsetOut');\n feMerge.append('feMergeNode').attr('in', 'SourceGraphic');\n\n // Add listener for when the browser or parent node resizes\n const resize = () => {\n if (!elem) {\n window.removeEventListener('resize', resize);\n return;\n }\n\n svgroot.attr('width', elem.offsetWidth).attr('height', elem.offsetHeight);\n };\n\n if (shouldResize) {\n window.addEventListener('resize', resize);\n }\n\n // Start initial render\n render(config);\n\n // return OnDestroy fn\n return () => {\n svgroot.remove();\n if (shouldResize) {\n window.removeEventListener('resize', resize);\n }\n };\n}\n","import { memo, useEffect, useRef } from 'react';\n\nimport { config as defaultConfig, type Config } from './chart/config';\nimport { initializeOrgChart } from './chart/index';\nimport type { TreeItem } from './types';\n\nconst defaultId = 'react-org-chart';\n\nexport type { TreeItem } from './types';\n\nexport type OrgChartProps = Partial<Config> & {\n id?: string;\n disableCanvasMouseMove?: boolean;\n disableCanvasMouseWheelZoom?: boolean;\n tree: TreeItem | TreeItem[];\n};\n\nfunction OrgChartComponent(props: OrgChartProps) {\n const {\n id = defaultId,\n disableCanvasMouseMove = false,\n disableCanvasMouseWheelZoom = false,\n tree,\n } = props;\n const anchor = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const onDestroy = initializeOrgChart({\n ...defaultConfig,\n ...props,\n id: `#${id}`,\n elem: anchor.current,\n data: tree,\n disableCanvasMouseMove,\n disableCanvasMouseWheelZoom,\n });\n\n return () => {\n onDestroy();\n };\n }, [props, id, tree, disableCanvasMouseMove, disableCanvasMouseWheelZoom]);\n\n return <div id={id} ref={anchor} style={{ width: '100%', height: '100%' }} />;\n}\n\nexport const OrgChart = memo(OrgChartComponent);\n"],"mappings":";;;;;;;;AAAA,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AAGrB,MAAM,YAAY;AAClB,MAAM,aAAa;AACnB,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Y;CAE9B,MAAM,UAAU,OAAO,OAAO,UAAU;AACxC,SAAQ,OAAO,cAAc,CAAC,KAAK,MAAM,YAAY;AACrD,SAAQ,OAAO,cAAc,CAAC,KAAK,MAAM,gBAAgB;CAGzD,MAAM,eAAe;AACnB,MAAI,CAAC,MAAM;AACT,UAAO,oBAAoB,UAAU,OAAO;AAC5C;;AAGF,UAAQ,KAAK,SAAS,KAAK,YAAY,CAAC,KAAK,UAAU,KAAK,aAAa;;AAG3E,KAAI,aACF,QAAO,iBAAiB,UAAU,OAAO;AAI3C,QAAOA,SAAO;AAGd,cAAa;AACX,UAAQ,QAAQ;AAChB,MAAI,aACF,QAAO,oBAAoB,UAAU,OAAO;;;;;;AC3KlD,MAAM,YAAY;AAWlB,SAAS,kBAAkB,OAAsB;CAC/C,MAAM,EACJ,KAAK,WACL,yBAAyB,OACzB,8BAA8B,OAC9B,SACE;CACJ,MAAM,SAAS,OAAuB,KAAK;AAE3C,iBAAgB;EACd,MAAM,YAAY,mBAAmB;GACnC,GAAGG;GACH,GAAG;GACH,IAAI,IAAI;GACR,MAAM,OAAO;GACb,MAAM;GACN;GACA;GACD,CAAC;AAEF,eAAa;AACX,cAAW;;IAEZ;EAAC;EAAO;EAAI;EAAM;EAAwB;EAA4B,CAAC;AAE1E,QAAO,oBAAC;EAAQ;EAAI,KAAK;EAAQ,OAAO;GAAE,OAAO;GAAQ,QAAQ;GAAQ;GAAI;;AAG/E,MAAa,WAAW,KAAK,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,70 +1,86 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctrl/react-orgchart",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Vx orgchart module",
|
|
5
|
-
"author": "Scott Cooper <scttcper@gmail.com>",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"repository": "scttcper/react-orgchart",
|
|
8
|
-
"sideEffects": false,
|
|
9
5
|
"keywords": [
|
|
10
6
|
"org chart"
|
|
11
7
|
],
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"demo:watch": "snowpack dev",
|
|
18
|
-
"demo:build": "snowpack build"
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"author": "Scott Cooper <scttcper@gmail.com>",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/scttcper/react-orgchart.git"
|
|
19
13
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"main": "./dist/index.js",
|
|
19
|
+
"module": "./dist/index.mjs",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.mjs",
|
|
25
|
+
"require": "./dist/index.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"lint": "oxfmt --check && oxlint .",
|
|
33
|
+
"lint:fix": "oxfmt && oxlint . --fix",
|
|
34
|
+
"build": "tsdown",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"test": "vitest run",
|
|
37
|
+
"test:watch": "vitest",
|
|
38
|
+
"dev": "vite",
|
|
39
|
+
"dev:build": "vite build",
|
|
40
|
+
"dev:preview": "vite preview",
|
|
41
|
+
"demo:watch": "vite",
|
|
42
|
+
"demo:build": "vite build",
|
|
43
|
+
"prepare": "pnpm build"
|
|
32
44
|
},
|
|
33
45
|
"dependencies": {
|
|
46
|
+
"d3-hierarchy": "^3.1.2",
|
|
34
47
|
"d3-selection": "^3.0.0",
|
|
35
|
-
"d3-
|
|
36
|
-
"d3-zoom": "^3.0.0"
|
|
37
|
-
"d3-shape": "^3.0.1",
|
|
38
|
-
"lodash.truncate": "^4.4.2"
|
|
48
|
+
"d3-shape": "^3.2.0",
|
|
49
|
+
"d3-zoom": "^3.0.0"
|
|
39
50
|
},
|
|
40
51
|
"devDependencies": {
|
|
41
|
-
"@ctrl/
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@types/d3-
|
|
48
|
-
"@types/d3-
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"@
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"react": "
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
52
|
+
"@ctrl/oxlint-config": "1.4.0",
|
|
53
|
+
"@faker-js/faker": "10.3.0",
|
|
54
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
55
|
+
"@testing-library/react": "16.3.2",
|
|
56
|
+
"@types/d3-hierarchy": "3.1.7",
|
|
57
|
+
"@types/d3-selection": "3.0.11",
|
|
58
|
+
"@types/d3-shape": "3.1.8",
|
|
59
|
+
"@types/d3-zoom": "3.0.8",
|
|
60
|
+
"@types/node": "25.2.3",
|
|
61
|
+
"@types/react": "19.2.14",
|
|
62
|
+
"@types/react-dom": "19.2.3",
|
|
63
|
+
"@vitejs/plugin-react": "5.1.4",
|
|
64
|
+
"jsdom": "28.1.0",
|
|
65
|
+
"oxfmt": "0.32.0",
|
|
66
|
+
"oxlint": "1.47.0",
|
|
67
|
+
"performant-array-to-tree": "1.11.0",
|
|
68
|
+
"react": "19.2.4",
|
|
69
|
+
"react-dom": "19.2.4",
|
|
70
|
+
"tsdown": "0.20.3",
|
|
71
|
+
"typescript": "5.9.3",
|
|
72
|
+
"vite": "7.3.1",
|
|
73
|
+
"vitest": "4.0.18"
|
|
63
74
|
},
|
|
64
|
-
"
|
|
65
|
-
"
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"react": "^19.0.0",
|
|
77
|
+
"react-dom": "^19.0.0"
|
|
66
78
|
},
|
|
67
79
|
"release": {
|
|
68
80
|
"branch": "master"
|
|
69
|
-
}
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=20"
|
|
84
|
+
},
|
|
85
|
+
"packageManager": "pnpm@10.29.3"
|
|
70
86
|
}
|
package/.circleci/config.yml
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
version: 2.1
|
|
2
|
-
orbs:
|
|
3
|
-
node: circleci/node@4
|
|
4
|
-
codecov: codecov/codecov@1
|
|
5
|
-
jobs:
|
|
6
|
-
test:
|
|
7
|
-
executor:
|
|
8
|
-
name: node/default
|
|
9
|
-
tag: 'current'
|
|
10
|
-
steps:
|
|
11
|
-
- checkout
|
|
12
|
-
- node/install-packages:
|
|
13
|
-
pkg-manager: yarn
|
|
14
|
-
- run:
|
|
15
|
-
name: build
|
|
16
|
-
command: yarn build
|
|
17
|
-
- run:
|
|
18
|
-
name: lint
|
|
19
|
-
command: yarn lint
|
|
20
|
-
release:
|
|
21
|
-
docker:
|
|
22
|
-
- image: cimg/node:current
|
|
23
|
-
steps:
|
|
24
|
-
- checkout
|
|
25
|
-
- node/install-packages:
|
|
26
|
-
pkg-manager: yarn
|
|
27
|
-
- run:
|
|
28
|
-
name: build
|
|
29
|
-
command: yarn build
|
|
30
|
-
- run: npx semantic-release
|
|
31
|
-
|
|
32
|
-
workflows:
|
|
33
|
-
version: 2
|
|
34
|
-
test_and_release:
|
|
35
|
-
# Run the test jobs first, then the release only when all the test jobs are successful
|
|
36
|
-
jobs:
|
|
37
|
-
- test
|
|
38
|
-
- release:
|
|
39
|
-
context:
|
|
40
|
-
- npm
|
|
41
|
-
filters:
|
|
42
|
-
branches:
|
|
43
|
-
only:
|
|
44
|
-
- master
|
|
45
|
-
requires:
|
|
46
|
-
- test
|
package/.editorconfig
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Editor configuration, see http://editorconfig.org
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
indent_style = space
|
|
6
|
-
end_of_line = lf
|
|
7
|
-
charset = utf-8
|
|
8
|
-
trim_trailing_whitespace = true
|
|
9
|
-
insert_final_newline = true
|
|
10
|
-
indent_size = 2
|
|
11
|
-
|
|
12
|
-
[*.md]
|
|
13
|
-
trim_trailing_whitespace = false
|
package/.eslintignore
DELETED
package/.eslintrc
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"env": {
|
|
4
|
-
"browser": true
|
|
5
|
-
},
|
|
6
|
-
"extends": ["@ctrl/eslint-config", "xo-react/space"],
|
|
7
|
-
"rules": {
|
|
8
|
-
"object-curly-spacing": ["error", "always"],
|
|
9
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
10
|
-
"no-mixed-operators": "off",
|
|
11
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
12
|
-
"@typescript-eslint/prefer-optional-chain": "off",
|
|
13
|
-
"@typescript-eslint/restrict-plus-operands": "off",
|
|
14
|
-
"react/jsx-tag-spacing": "off"
|
|
15
|
-
}
|
|
16
|
-
}
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
16
|
package/.prettierrc
DELETED
package/demo/App.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { arrayToTree } from 'performant-array-to-tree';
|
|
3
|
-
|
|
4
|
-
import { OrgChart } from '../src';
|
|
5
|
-
import { data } from './testdata';
|
|
6
|
-
|
|
7
|
-
// @ts-expect-error
|
|
8
|
-
import avatarPersonnel from './assets/avatar-personnel.svg';
|
|
9
|
-
|
|
10
|
-
const tree = arrayToTree(
|
|
11
|
-
data.map(x => ({ ...x, entity: { ...x, avatar: avatarPersonnel }, parentId: x.reportsTo?.id })),
|
|
12
|
-
{ dataField: null },
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export default class App extends React.Component {
|
|
16
|
-
render() {
|
|
17
|
-
// For downloading org chart as image or pdf based on id
|
|
18
|
-
return <OrgChart tree={tree[0]} />;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg width="96" height="96" viewBox="0 0 96 96" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><rect id="a" width="96" height="96" rx="48"/></defs><g fill="none" fill-rule="evenodd"><use fill="#F5F9FF" xlink:href="#a"/><path d="M62.297 53.094c1.666.416 3.034 1.302 4.101 2.656C67.466 57.104 68 58.64 68 60.36v2.89c0 1.042-.365 1.927-1.094 2.656-.729.73-1.614 1.094-2.656 1.094h-32.5c-1.042 0-1.927-.365-2.656-1.094-.73-.729-1.094-1.614-1.094-2.656v-2.89c0-1.72.534-3.256 1.602-4.61 1.067-1.354 2.434-2.24 4.101-2.656l5.547-1.406c2.448 1.77 5.208 2.708 8.281 2.812 3.386.104 6.459-.833 9.219-2.812l5.547 1.406zM48 24c2.24 0 4.323.56 6.25 1.68a12.411 12.411 0 0 1 4.57 4.57 12.227 12.227 0 0 1 1.68 6.25c0 2.24-.56 4.323-1.68 6.25a12.411 12.411 0 0 1-4.57 4.57A12.227 12.227 0 0 1 48 49c-2.24 0-4.323-.56-6.25-1.68a12.411 12.411 0 0 1-4.57-4.57 12.227 12.227 0 0 1-1.68-6.25c0-2.24.56-4.323 1.68-6.25a12.411 12.411 0 0 1 4.57-4.57A12.227 12.227 0 0 1 48 24z" stroke="#302839" stroke-width="4"/></g></svg>
|
package/demo/index.css
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
html,
|
|
2
|
-
body {
|
|
3
|
-
margin: 0;
|
|
4
|
-
height: 100%;
|
|
5
|
-
width: 100%;
|
|
6
|
-
font-size: 12px;
|
|
7
|
-
font-family: 'SF UI Text', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
|
|
8
|
-
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
9
|
-
-webkit-font-smoothing: antialiased;
|
|
10
|
-
background-color: aliceblue;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
#root {
|
|
15
|
-
margin: auto;
|
|
16
|
-
cursor: move;
|
|
17
|
-
height: 100vh;
|
|
18
|
-
width: 100vw;
|
|
19
|
-
background-color: #fff;
|
|
20
|
-
overflow: hidden;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.org-chart-entity-link:hover g {
|
|
24
|
-
fill: #409cf9 !important;
|
|
25
|
-
}
|
|
26
|
-
.org-chart-node .org-chart-counts {
|
|
27
|
-
fill: #409cf9 !important;
|
|
28
|
-
}
|
package/demo/index.html
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
-
<meta name="description" content="A react component for Google Orgchart" />
|
|
7
|
-
<link rel="stylesheet" href="/index.css" />
|
|
8
|
-
<title>React Orgchart</title>
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<div id="root"></div>
|
|
12
|
-
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
13
|
-
<script type="module" src="/index.js"></script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
package/demo/index.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import App from './App';
|
|
4
|
-
|
|
5
|
-
ReactDOM.render(
|
|
6
|
-
<React.StrictMode>
|
|
7
|
-
<App />
|
|
8
|
-
</React.StrictMode>,
|
|
9
|
-
document.getElementById('root'),
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
// HMR Code Snippet Example
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
if (import.meta.hot) {
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
import.meta.hot.accept(({ module }) => {
|
|
17
|
-
// Accept the module, apply it into your application.
|
|
18
|
-
});
|
|
19
|
-
}
|