@molecule/app-info-display-angular

Feature · info-display · App (browser) · v1.1.1 · Apache-2.0

InfoCard and DefinitionList for structured label/value metadata display

npm install @molecule/app-info-display-angular

npm · Source on GitHub

How it works

@molecule/app-info-display-angular is a ready-made info-display feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { Component } from '@angular/core'
import { InfoCard } from '@molecule/app-info-display-angular'

@Component({
  selector: 'app-company-details',
  standalone: true,
  imports: [InfoCard],
  template: `
    <div
      mol-info-card
      dataMolId="company-info-card"
      [columns]="2"
      [fields]="[
        { label: 'Industry', value: 'Technology' },
        { label: 'Founded', value: '2018' },
        { label: 'Employees', value: '120–150' },
      ]"
    >
      <h3 slot="title">Company Details</h3>
    </div>
  `,
})
export class CompanyDetails {}

Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular

Reference

Angular InfoCard and DefinitionList for structured label/value metadata.

Exports:

  • <div mol-info-card> — Card-wrapped DefinitionList with title, icon, actions.
  • <dl mol-definition-list> — standalone label/value grid.
  • DefinitionField type.

This is the Angular counterpart of @molecule/app-info-display-react: the same export names, the same props (React names), and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { Component } from '@angular/core'
import { InfoCard } from '@molecule/app-info-display-angular'

@Component({
  selector: 'app-company-details',
  standalone: true,
  imports: [InfoCard],
  template: `
    <div
      mol-info-card
      dataMolId="company-info-card"
      [columns]="2"
      [fields]="[
        { label: 'Industry', value: 'Technology' },
        { label: 'Founded', value: '2018' },
        { label: 'Employees', value: '120–150' },
      ]"
    >
      <h3 slot="title">Company Details</h3>
    </div>
  `,
})
export class CompanyDetails {}

Type

feature

Installation

npm install @molecule/app-info-display-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

DefinitionField

A single label/value pair rendered inside a DefinitionList.

interface DefinitionField {
  /** Label content: a `TemplateRef` or plain text, shown beside the field's icon. */
  label: unknown
  /** Rendered value: a `TemplateRef` or plain text. */
  value: unknown
  /** Optional icon rendered to the left of the label: a `TemplateRef` or plain text. */
  icon?: unknown
}

DefinitionListProps

Props accepted by the DefinitionList component.

interface DefinitionListProps {
  /** Fields to render. */
  fields: DefinitionField[]
  /** Grid column count. Defaults to `1`. */
  columns?: 1 | 2 | 3
  /** Extra classes. */
  className?: string
}

InfoCardProps

Props accepted by InfoCard — the same props @molecule/app-info-display-react accepts. Node props (title, icon, actions) are projected content in Angular (an input cannot carry a node), so they are typed unknown: pass them in the host template, not as values.

interface InfoCardProps {
  /** Card heading, projected as `[slot=title]` content. */
  title?: unknown
  /** Optional leading icon, projected as `[slot=icon]` content. */
  icon?: unknown
  /** Optional right-side header actions, projected as `[slot=actions]` content. */
  actions?: unknown
  /** Structured fields to display. */
  fields: DefinitionField[]
  /**
   * Grid column count — `1` stacks labels above values, `2+` puts labels beside
   * values. Defaults to `1`.
   */
  columns?: 1 | 2 | 3
  /** Extra classes on the outer Card. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
}

Classes

DefinitionList

DefinitionList component.

Structured label/value pair list, standalone or inside InfoCard-style cards. The host IS the <dl> (dl[mol-definition-list]), matching React's root exactly. columns={1} stacks each label above its value; 2/3 arrange the fields in a grid. Node-valued label, value and icon fields are ng-template references rendered through NgTemplateOutlet; string / number fields render as text — React's contract.

@Component({
  selector: 'dl[mol-definition-list]',
  standalone: true,
  imports: [NgTemplateOutlet],
  inputs: ['fields', 'columns', 'className'],
  host: {
    '[class]': 'listClasses()',
  },
  // prettier-ignore
  template: `@for (field of fields; track $index) {<div [class]="itemClasses()"><dt [class]="termClasses()">@if (templateOf(field.icon); as icon) {<ng-container [ngTemplateOutlet]="icon" />}@else if (textOf(field.icon)) {<ng-container>{{ textOf(field.icon) }}</ng-container>}<span>@if (templateOf(field.label); as label) {<ng-container [ngTemplateOutlet]="label" />}@else {<ng-container>{{ textOf(field.label) }}</ng-container>}</span></dt><dd [class]="valueClasses()">@if (templateOf(field.value); as value) {<ng-container [ngTemplateOutlet]="value" />}@else {<ng-container>{{ textOf(field.value) }}</ng-container>}</dd></div>}`,
})
export class DefinitionList {
  /** Fields to render. */
  fields!: DefinitionField[]
  /** Grid column count (React's default parameter: `1` at read time). */
  columns?: 1 | 2 | 3
  /** Extra classes. */
  className?: string

  /**
   * The current class map.
   * @returns The UIClassMap.
   */
  cm(): UIClassMap {
    return getClassMap()
  }

  /**
   * The effective column count (React's `columns = 1` default).
   * @returns The column count.
   */
  columnsValue(): 1 | 2 | 3 {
    return this.columns ?? 1
  }

  /**
   * Computes the list class list: a stack at one column, a grid above it.
   * @returns The class string.
   */
  listClasses(): string {
    return this.cm().cn(
      this.columnsValue() === 1
        ? this.cm().stack(3)
        : this.cm().grid({ cols: this.columnsValue(), gap: 'md' }),
      this.className,
    )
  }

  /**
   * The per-field wrapper class (`cm.stack(0)`).
   * @returns The class string.
   */
  itemClasses(): string {
    return this.cm().stack(0)
  }

  /**
   * The term class (`cm.textSize('xs')` + `cm.fontWeight('semibold')` +
   * `cm.flex({ align: 'center', gap: 'xs' })`).
   * @returns The class string.
   */
  termClasses(): string {
    return this.cm().cn(
      this.cm().textSize('xs'),
      this.cm().fontWeight('semibold'),
      this.cm().flex({ align: 'center', gap: 'xs' }),
    )
  }

  /**
   * The value class (`cm.textSize('sm')`).
   * @returns The class string.
   */
  valueClasses(): string {
    return this.cm().textSize('sm')
  }

  /**
   * A node-valued field as a template, when it is one.
   * @param value - The field value.
   * @returns The template, or null for text.
   */
  templateOf(value: unknown): TemplateRef<unknown> | null {
    return asTemplate(value)
  }

  /**
   * The text a field renders (React renders strings and numbers as text).
   * @param value - The field value.
   * @returns The text, or `''` for a node field.
   */
  textOf(value: unknown): string {
    return typeof value === 'string' || typeof value === 'number' ? String(value) : ''
  }
}

InfoCard

InfoCard component.

Card wrapping a <dl mol-definition-list> of metadata fields. The host IS the card's root <div> (div[mol-info-card]), matching React's root exactly: React renders <Card className data-mol-id> — whose Card defaults are variant elevated and padding md — so the host wears that same class list. The heading, its leading icon and the header actions are projected content ([slot=title], [slot=icon], [slot=actions]).

Used all over CRM/helpdesk/finance detail pages (CompanyInfoCard, DealInfoCard, TicketDetailsCard, TransactionDetailsCard) — same shape everywhere, only the fields differ.

@Component({
  selector: 'div[mol-info-card]',
  standalone: true,
  imports: [DefinitionList],
  inputs: ['fields', 'columns', 'className', 'dataMolId'],
  host: {
    '[class]': 'classes()',
    '[attr.data-mol-id]': 'dataMolId ?? null',
  },
  // prettier-ignore
  template: `<div [class]="stackClasses()"><header [class]="headerClasses()"><div [class]="innerClasses()"><ng-content select="[slot=icon]"></ng-content><h3 [class]="titleClasses()"><ng-content select="[slot=title]"></ng-content></h3></div><ng-content select="[slot=actions]"></ng-content></header><dl mol-definition-list [fields]="fields" [columns]="columnsValue()"></dl></div>`,
})
export class InfoCard {
  /** Structured fields to display. */
  fields!: DefinitionField[]
  /** Grid column count (React's default parameter: `1` at read time). */
  columns?: 1 | 2 | 3
  /** Extra classes on the outer Card. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string

  /**
   * The current class map.
   * @returns The UIClassMap.
   */
  cm(): UIClassMap {
    return getClassMap()
  }

  /**
   * The effective column count (React's `columns = 1` default).
   * @returns The column count.
   */
  columnsValue(): 1 | 2 | 3 {
    return this.columns ?? 1
  }

  /**
   * The host's class list: the Card surface React renders (variant
   * `elevated`, padding `md`, not interactive) plus `className`.
   * @returns The class string.
   */
  classes(): string {
    return this.cm().cn(
      this.cm().card({ variant: 'elevated' }),
      this.cm().cardPadding('md'),
      this.className,
    )
  }

  /**
   * The body class (`cm.stack(3)`).
   * @returns The class string.
   */
  stackClasses(): string {
    return this.cm().stack(3)
  }

  /**
   * The header class (`cm.flex({ justify: 'between', align: 'center', gap: 'sm' })`).
   * @returns The class string.
   */
  headerClasses(): string {
    return this.cm().flex({ justify: 'between', align: 'center', gap: 'sm' })
  }

  /**
   * The heading row class (`cm.flex({ align: 'center', gap: 'sm' })`).
   * @returns The class string.
   */
  innerClasses(): string {
    return this.cm().flex({ align: 'center', gap: 'sm' })
  }

  /**
   * The title class (`cm.textSize('base')` + `cm.fontWeight('semibold')`).
   * @returns The class string.
   */
  titleClasses(): string {
    return this.cm().cn(this.cm().textSize('base'), this.cm().fontWeight('semibold'))
  }
}

Injection Notes

Requirements

Peer dependencies:

  • @angular/common ^22.0.0
  • @angular/core ^22.0.0
  • @angular/platform-browser ^22.0.0
  • @molecule/app-angular ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-angular ^1.1.0

Runtime Dependencies

  • @angular/common
  • @angular/core
  • @angular/platform-browser
  • @molecule/app-angular
  • @molecule/app-ui
  • @molecule/app-ui-angular

Purely presentational: pass already-formatted / already-translated content as fields and projected slots. getClassMap() requires a bonded ClassMap (e.g. @molecule/app-ui-tailwind) — there is no other wiring. columns={1} stacks label above value; 2/3 arrange fields in a grid. Node props are projected content: title, icon and actions are selected by [slot=title], [slot=icon] and [slot=actions]. A field's label, value and icon take an ng-template reference or plain text.