INNER CODE UNIT · TypeScript

componentProps

f5/unovis · packages/mcp/src/codegen/index.ts:163

function componentProps (component: ComponentSpec, emit: Emit): Prop[] {
  return Object.entries(component.config)
    .map(([name, value]) => {
      const enumName = ENUM_PROPS[name]
      if (enumName && typeof value === 'string') {
        emit.enumImports.add(enumName)
        return { name, expr: `${enumName}.${enumMember(value)}` }
      }
      const expr = valueExpression(value, emit)
      return expr === undefined ? undefined : { name, expr }
    })
    .filter((p): p is Prop => p !== undefined)
}

function axisProps (spec: ChartSpec, axis: 'x' | 'y', emit: Emit): Prop[] | undefined {
  const config = axis === 'x' ? spec.xAxis : spec.yAxis
  if (!config) return undefined
  const props: Prop[] = [{ name: 'type', expr: `'${axis}'` }]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…