npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@molecule/app-feature-chapter-list-angular

v1.1.2

Published

List of chapters with seek-to and progress highlight — chapter thumbnails, titles, and timestamps for podcast/video playback

Readme

@molecule/app-feature-chapter-list-angular

Angular chapter list — the counterpart of @molecule/app-feature-chapter-list-react: the same exports, the same props (React names) and the same DOM for the same input.

Used by podcast and video-streaming surfaces for in-episode chapter navigation. <ChapterList> (mol-chapter-list) renders a scrollable list of chapters with seek-to-on-click and a progress highlight for the chapter the playhead is currently inside.

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 { ChapterList } from '@molecule/app-feature-chapter-list-angular'

@Component({
  selector: 'app-player',
  standalone: true,
  imports: [ChapterList],
  template: `
    <mol-chapter-list
      [chapters]="chapters"
      [currentTime]="currentTime"
      [onSeek]="seek"
    ></mol-chapter-list>
  `,
})
export class Player {
  currentTime = 150
  chapters = [
    { id: 'c1', title: 'Intro', startTime: 0 },
    { id: 'c2', title: 'Topic A', startTime: 120, thumbnail: '/a.jpg' },
    { id: 'c3', title: 'Outro', startTime: 1800 },
  ]

  seek = (startTime: number): void => {
    this.currentTime = startTime
  }
}

Type

feature

Installation

npm install @molecule/app-feature-chapter-list-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

Chapter

A single chapter entry inside an episode / video / podcast track. id is used as the stable row key, startTime is in seconds and drives both the displayed timestamp and the currentTime-based highlight. thumbnail is an optional small image (square) shown to the left of the title.

interface Chapter {
  /** Stable identifier for the chapter (used as the row key). */
  id: string
  /** Chapter title shown as the primary label of the row. */
  title: string
  /** Chapter start time in seconds (used for ordering + seek + highlight). */
  startTime: number
  /** Optional thumbnail image URL (square). */
  thumbnail?: string
}

ChapterListProps

Props accepted by {@link ChapterList} — the same props @molecule/app-feature-chapter-list-react accepts. rowTrailing is a render function in React, so it is a TemplateRef here (an input cannot carry a node): its context exposes the row's chapter as a0, matching React's rowTrailing(chapter) call.

interface ChapterListProps {
  /**
   * Chapters to render. Order is preserved as-is (callers should pass
   * them in `startTime` order). The "current" chapter is the last one
   * whose `startTime` is `<= currentTime`.
   */
  chapters: Chapter[]
  /**
   * Current playback time in seconds. The chapter whose `startTime` is
   * the largest value `<= currentTime` is highlighted as the active
   * chapter. Pass `0` if playback hasn't started yet.
   */
  currentTime: number
  /**
   * Optional click handler called with the chapter's `startTime` when a
   * row is activated. When omitted the rows render as static, non-
   * interactive elements.
   */
  onSeek?: (startTime: number) => void
  /** Extra classes merged onto the root element. */
  className?: string
  /** Per-row trailing template; its context has `a0` = the row's chapter. */
  rowTrailing?: TemplateRef<unknown>
}

Classes

ChapterList

ChapterList component.

Scrollable list of chapters with seek-to-on-click and a progress highlight for the chapter the playhead is currently inside, the Angular counterpart of @molecule/app-feature-chapter-list-react: the same props (React names), the same ClassMap tokens, the same i18n keys and the same DOM for the same input.

React's root element flips between <div role="region"> (no chapters) and <ul role="list"> (chapters), so the rendered root stands in front of the host's place and the host itself leaves the page (placeContentBefore + setElementPresent).

All styling routes through getClassMap() (no raw class names). All user-visible text routes through t() so the list translates via the companion @molecule/app-locales-feature-chapter-list locale bond.

@Component({
  selector: 'mol-chapter-list',
  standalone: true,
  imports: [NgTemplateOutlet],
  hostDirectives: [MolPlacement],
  inputs: ['chapters', 'currentTime', 'onSeek', 'className', 'rowTrailing'],
  template: `@if (chapters.length === 0) {
      <div
        role="region"
        [attr.aria-label]="regionLabel()"
        data-mol-id="chapter-list"
        [class]="emptyRootClasses()"
      >
        <p [class]="emptyMessageClasses()" data-mol-id="chapter-list-empty">{{ emptyLabel() }}</p>
      </div>
    } @else {
      <ul
        role="list"
        [attr.aria-label]="regionLabel()"
        data-mol-id="chapter-list"
        [class]="listClasses()"
        style="list-style: none; padding: 0px; margin: 0px"
      >
        @for (chapter of chapters; track chapter.id; let i = $index) {
          <li
            data-mol-id="chapter-list-row"
            [attr.data-active]="isActive(i) ? 'true' : 'false'"
            [attr.data-chapter-id]="chapter.id"
          >
            @if (onSeek) {
              <button
                type="button"
                (click)="seek(chapter)"
                [attr.aria-label]="seekLabel(chapter)"
                [attr.aria-current]="isActive(i) ? 'true' : null"
                data-mol-id="chapter-list-row-button"
                [class]="buttonClasses()"
                style="display: block; width: 100%; text-align: left; background: transparent; border: medium; padding: 0px"
              >
                <ng-container
                  [ngTemplateOutlet]="rowBody"
                  [ngTemplateOutletContext]="rowContext(chapter, i)"
                ></ng-container>
              </button>
            } @else {
              <div
                [attr.aria-current]="isActive(i) ? 'true' : null"
                data-mol-id="chapter-list-row-static"
              >
                <ng-container
                  [ngTemplateOutlet]="rowBody"
                  [ngTemplateOutletContext]="rowContext(chapter, i)"
                ></ng-container>
              </div>
            }
          </li>
        }
      </ul>
    }
    <ng-template #rowBody let-chapter="chapter" let-active="isActive">
      <div [class]="rowContentClasses()" data-mol-id="chapter-list-row-content">
        <div
          [class]="thumbnailWrapClasses()"
          data-mol-id="chapter-list-row-thumbnail"
          style="width: 48px; height: 48px"
        >
          @if (chapter.thumbnail) {
            <img
              [attr.src]="chapter.thumbnail"
              [attr.alt]="thumbnailAlt(chapter)"
              style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px"
            />
          } @else {
            <div aria-hidden="true" style="width: 100%; height: 100%; border-radius: 4px"></div>
          }
        </div>
        <div
          [class]="metaClasses()"
          data-mol-id="chapter-list-row-meta"
          style="min-width: 0px; flex: 1 1 0%"
        >
          <span
            [class]="titleClasses()"
            data-mol-id="chapter-list-row-title"
            style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block"
            >{{ chapter.title }}</span
          >
          <span [class]="timestampClasses()" data-mol-id="chapter-list-row-timestamp">{{
            timestampText(chapter, active)
          }}</span>
        </div>
        @if (rowTrailing) {
          <div [class]="trailingClasses()" data-mol-id="chapter-list-row-trailing">
            <ng-container
              [ngTemplateOutlet]="rowTrailing"
              [ngTemplateOutletContext]="trailingContext(chapter)"
            ></ng-container>
          </div>
        }
      </div>
    </ng-template>`,
})
export class ChapterList {
  /** Chapters to render, in start-time order (React's `chapters`). */
  chapters: Chapter[] = []
  /** Current playback time in seconds (React's `currentTime`). */
  currentTime = 0
  /** Called with the chapter's `startTime` when a row is activated. */
  onSeek?: (startTime: number) => void
  /** Extra classes merged onto the root element. */
  className?: string
  rowTrailing?: TemplateRef<unknown>

  /** The i18n handle (locale-reactive), read in an injection context. */
  private readonly i18n = useTranslation()

  private readonly host: ElementRef<HTMLElement> = inject(ElementRef)

  constructor() {
    // place and the host leaves the page.
    usePlacement(() => {
      placeContentBefore(this.host.nativeElement, this.host.nativeElement)
      setElementPresent(this.host.nativeElement, false)
    })
  }

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

  /** The index of the active chapter for the current playback time. */
  activeIndex(): number {
    return findActiveChapterIndex(this.chapters, this.currentTime)
  }

  /** Whether the chapter at this index is the active one. */
  isActive(index: number): boolean {
    return index === this.activeIndex()
  }

  /** Calls React's `onSeek(chapter.startTime)` for a clicked row. */
  seek(chapter: Chapter): void {
    this.onSeek?.(chapter.startTime)
  }

  /** The translated region / list label. */
  regionLabel(): string {
    return this.i18n.t('chapterList.aria.region', {}, { defaultValue: 'Chapters' })
  }

  /** The translated empty-state message. */
  emptyLabel(): string {
    return this.i18n.t(
      'chapterList.empty',
      {},
      { defaultValue: 'No chapters available for this episode.' },
    )
  }

  seekLabel(chapter: Chapter): string {
    return this.i18n.t(
      'chapterList.aria.seek',
      { title: chapter.title, timestamp: formatTimestamp(chapter.startTime) },
      { defaultValue: 'Jump to {{title}} at {{timestamp}}' },
    )
  }

  /** React's `t('chapterList.aria.thumbnail', { title })` for a row. */
  thumbnailAlt(chapter: Chapter): string {
    return this.i18n.t(
      'chapterList.aria.thumbnail',
      { title: chapter.title },
      { defaultValue: 'Thumbnail for {{title}}' },
    )
  }

  timestampText(chapter: Chapter, active: boolean): string {
    const badge = this.i18n.t('chapterList.current', {}, { defaultValue: 'Now playing' })
    return `${formatTimestamp(chapter.startTime)}${active ? ` · ${badge}` : ''}`
  }

  /** The template context for one row. */
  rowContext(chapter: Chapter, index: number): Record<string, unknown> {
    return { chapter, isActive: this.isActive(index) }
  }

  trailingContext(chapter: Chapter): Record<string, unknown> {
    return { a0: chapter }
  }

  emptyRootClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.sp('p', 3), this.className)
  }

  /** The empty-state message's class list (`cm.textSize('sm')`). */
  emptyMessageClasses(): string {
    return this.cm().cn(this.cm().textSize('sm'))
  }

  /** The populated list's class list (`cm.stack(0)` + `className`). */
  listClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.stack(0), this.className)
  }

  /** The seek button's class list (`cm.cursorPointer`). */
  buttonClasses(): string {
    return this.cm().cn(this.cm().cursorPointer)
  }

  /** The row content's class list (`cm.flex(...)` + `cm.sp('p', 2)`). */
  rowContentClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.flex({ align: 'center', gap: 'md' }), cm.sp('p', 2))
  }

  /** The thumbnail wrapper's class list (`cm.shrink0`). */
  thumbnailWrapClasses(): string {
    return this.cm().cn(this.cm().shrink0)
  }

  /** The row meta column's class list (`cm.stack(0)`). */
  metaClasses(): string {
    return this.cm().cn(this.cm().stack(0))
  }

  titleClasses(): string {
    const cm = this.cm()
    return cm.cn(cm.textSize('sm'), cm.fontWeight('semibold'))
  }

  /** The row timestamp's class list (`cm.textSize('xs')`). */
  timestampClasses(): string {
    return this.cm().textSize('xs')
  }

  /** The trailing slot's class list (`cm.shrink0`). */
  trailingClasses(): string {
    return this.cm().cn(this.cm().shrink0)
  }
}

(Member comments are shortened to their first sentence, and the 8 longest are left out to fit; the full declaration is in node_modules/@molecule/app-feature-chapter-list-angular/dist/chapter-list.component.d.ts.)

Functions

formatTimestamp(seconds)

Format a number of seconds as m:ss or h:mm:ss (or 0:00 for non-finite / negative input). Used for chapter timestamps.

function formatTimestamp(seconds: number): string
  • seconds — Seconds to format.

Returns: The formatted timestamp string.

findActiveChapterIndex(chapters, currentTime)

Find the index of the active chapter for a given currentTime. Returns the index of the last chapter whose startTime is <= currentTime. Returns -1 when chapters is empty or currentTime is before the first chapter.

function findActiveChapterIndex(chapters: Chapter[], currentTime: number): number
  • chapters — Chapters in start-time order.
  • currentTime — Current playback time in seconds.

Returns: The active chapter index, or -1.

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.13.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

  • Requires a bonded ClassMap (setClassMap() at startup) and an i18n provider (for the region, empty-state and row labels) or rendering throws.

  • The active chapter is the last one whose startTime is <= currentTime; it carries data-active="true" and aria-current="true" plus the "Now playing" badge.

  • When onSeek is omitted the rows render as static, non-interactive elements. rowTrailing is a TemplateRef whose context carries the row's chapter as a0 (React's rowTrailing(chapter)), for a trailing slot such as a download button.

  • Translations live in the companion @molecule/app-locales-feature-chapter-list bond.

Translations

Translation strings are provided by @molecule/app-locales-feature-chapter-list.