INNER CODE UNIT · TypeScript
used
f5/unovis · packages/mcp/src/codegen/index.ts:267
const used = [`Vis${containerName(spec)}`, ...components.map(c => tag(c.type)), ...(xAxis || yAxis ? ['VisAxis'] : [])]
const legendTag = spec.legend?.length ? `<VisBulletLegend items={${json(spec.legend.map(i => ({ name: i.name })), 0)}} />\n ` : ''
if (spec.legend?.length) used.push('VisBulletLegend')
const pkg = framework === 'react' ? '@unovis/react' : '@unovis/solid'
const header = framework === 'react'
? `import React from 'react'\nimport { ${[...new Set(used)].sort().join(', ')} } from '${pkg}'`
: `import type { JSX } from 'solid-js'\nimport { ${[...new Set(used)].sort().join(', ')} } from '${pkg}'`
const signature = framework === 'react'
? 'export default function Chart (): JSX.Element {'
: 'const Chart = (): JSX.Element => {'
const footer = framework === 'react' ? '}' : '}\n\nexport default Chart'
const content = `${header}
${preamble(emit, `const data = ${dataLiteralFor(spec.data)}`, true)}
${signature}