@firestitch/grid

中文文档
18.3.0发布于 2026/11/01MITTypeScriptES Module

A virtual-scrolling grid for Angular 18 that shows either a pivot (row levels, column levels and values) or a source's own lines (details), with sorts and filters on every column header, expandable groups, total rows and columns, and a layout panel docked

原始使用文档
文档目录8 节
  1. Install
  2. Usage
  3. Inputs
  4. The source
  5. Layout helpers
  6. Styles
  7. Development
  8. License

@firestitch/grid

A virtual-scrolling grid for Angular 18 that shows either a pivot (row levels, column levels and values) or a source's own lines (details), with sorts and filters on every column header, expandable groups, total rows and columns, and a layout panel docked beside it. The grid never holds a dataset: it asks a GridSource for the rows on screen and reads more as the viewer scrolls and opens groups.

Install

npm install @firestitch/grid

Like every Firestitch package, the grid declares no peer dependencies. The app installs the packages the grid imports itself:

PackageVersionUsed for
@angular/core, common, forms, cdk, material^18.2.7
rxjs^7.5.6
@firestitch/chip^18.0.70the layout panel's field chips
@firestitch/menu^18.0.5header and layout panel menus
@firestitch/resize^18.0.3the layout panel's resize edge
@firestitch/style^18.0.70the --fs-* colour tokens the grid paints with
@firestitch/datepicker^18.0.29date column filters
@firestitch/form^18.0.41filter panel validation
@firestitch/popover^18.1.0the filter panel and truncated cells (panel mode, added in 18.1.0)

An app must install every one of them, @firestitch/datepicker, @firestitch/form and @firestitch/popover included: the app does not build without them, and @firestitch/popover must be 18.1.0 or later. @firestitch/datepicker and @firestitch/form import @firestitch/clear, common, date, dialog, drawer, message and scroll-picker, and @firestitch/drawer needs @firestitch/core and @firestitch/store. An app that already uses fs-datepicker has them.

Usage

fs-grid is a standalone component.

import { HttpClient } from '@angular/common/http';
import { Component, inject, signal } from '@angular/core';

import {
  FsGridComponent,
  GridAggregation,
  GridGranularity,
  GridLayout,
  GridResult,
  GridSource,
} from '@firestitch/grid';

@Component({
  selector: 'app-sales-grid',
  standalone: true,
  imports: [FsGridComponent],
  template: '<fs-grid [source]="source" [(layout)]="layout"></fs-grid>',
})
export class SalesGridComponent {
  public layout = signal<GridLayout>({
    rows: [{ field: 'region' }],
    columns: [{ field: 'orderedOn', granularity: GridGranularity.Month }],
    values: [{ field: 'revenue', aggregation: GridAggregation.Sum }],
    totalRow: true,
  });

  public source: GridSource = {
    read: (request, params) => this._http.post<GridResult>('/sales/grid', { request, params }),
  };

  private _http = inject(HttpClient);
}

Inputs

InputType
sourceGridSourceRequired. The only way the grid reaches its data.
[(layout)]GridLayoutRequired. Sorts, filters, header drags and the layout panel write it back, canonical.
controlsGridControlsWhat the viewer may change (sort, expand, layout, filter): enabled, disabled or hidden. A control left out is enabled.
paramsGridParamsThe host's own values, carried on every read. The grid never looks inside.
[(expansion)]GridExpansionWhich groups are open: every group down to depth, then the viewer's own opens and closes.
[(panel)]GridPanel | nullThe panel docked beside the grid; null when none is open.
formatterGridFormatterWrites every value the grid shows, so the screen and the host's own files read the same. The grid's en-US formatter is used when absent.
clearedFilter{ field, granularity } | nullA date filter the host took out when the grain its params drive changed; the status line names it.

The source

export interface GridSource {
  read(request: GridRequest, params: GridParams): Observable<GridResult>;
}
  • Each emit is a part of the answer, and complete means done.
  • The read is cold, and unsubscribing aborts it. The grid cancels reads it no longer needs.
  • request.rows names the row ranges wanted, request.columns the column range, and request.fields asks for the source's fields and limits too.
  • An error arrives as an Error with a readable message; the grid shows it with a Retry.

Layout helpers

  • canonicalGridLayout(layout) gives the layout as a host stores and compares it: defaults are left out and keys come in one order, so two layouts that mean the same have the same JSON.
  • normalizeGridLayout(layout) is the forgiving read: unknown keys and entries without a field are dropped, and every list and flag comes back present.

Styles

The grid paints from its own component styles, the --fs-* tokens of @firestitch/style and the Angular Material theme. There is nothing to include: the package's styles.scss is empty and ships only so the build lays out like the other Firestitch packages.

Development

npm run serve     # the playground, with every example
npm run check     # the engine, contract and client checks
npm run package   # the checks, then package/ with this README and the LICENSE

License

MIT. See LICENSE.

版本与发布记录

@firestitch/grid 共发布 9 个版本,首次发布于 2026/10/07;过去 12 个月发布了 9 个版本。

版本发布日期距今
18.3.0latest2026/11/012 天前
18.2.22026/10/312 天前
18.2.12026/10/313 天前
18.2.02026/10/313 天前
18.1.32026/10/285 天前
18.1.22026/10/1617 天前

关于 @firestitch/grid 的常见问题

@firestitch/grid 是什么?

Angular 18中的虚拟滚动网格,可以显示枢轴(行级别、列级别和值),也可以显示源代码自己的行(详细信息),每个列标头都有排序和过滤器、可扩展的组、总行和列,以及停靠的布局面板

如何安装 @firestitch/grid?

在项目目录运行 npm install @firestitch/grid,或使用 pnpm add / yarn add / bun add。

@firestitch/grid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@firestitch/grid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@firestitch/grid 可以商用吗?

@firestitch/grid 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@firestitch/grid 还在维护吗?

最新版本 18.3.0 发布于 2026/11/01(2 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/10/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。