import { BasePlugin, Plugin } from "../../plugins/index.js"; import { Column } from "../column.js"; import { Row } from "../row.js"; import { ColumnOptionsFor, SignatureFrom } from "./plugins.js"; import { Constructor } from "../private-types.js"; import { ComponentLike, ContentValue } from '@glint/template'; interface CellContext { column: Column; row: Row; } type ColumnPluginOption

= P extends BasePlugin ? [Constructor

, () => ColumnOptionsFor>] : [P | Constructor

, () => unknown]; type CellOptions = { /** * when no value is present for a given set of data for the given column config */ defaultValue?: string; } & Record; interface ColumnConfig { /** * the `key` is required for preferences storage, as well as * managing uniqueness of the columns in an easy-to-understand way. * * key may be anything if a `value` is provided, but _should_ * be a property-path on each data object passed to the table. * * @example `someObj.property.path` * @example `someProperty` */ key: string; /** * Optionally provide a function to determine the value of a row at this column */ value?: (context: CellContext) => ContentValue; /** * Recommended property to use for custom components for each cell per column. * Out-of-the-box, this property isn't used, but the provided type may be * a convenience for consumers of the headless table */ Cell?: ComponentLike; /** * The name or title of the column, shown in the column heading / th */ name?: string; /** * Bag of extra properties to pass to Cell via `@options`, if desired */ options?: (context: CellContext) => CellOptions; /** * Each plugin may provide column options, and provides similar syntax to how * options for the table are specified in the plugins entry, * * ```js * pluginOptions: [ * ColumnVisibility.forColumn(() => ({ isVisible: false })), * StickyColumns.forColumn(() => ({ sticky: 'right' })), * ], * ``` */ pluginOptions?: ColumnPluginOption[]; } type ColumnKey = NonNullable['key']>; export { CellContext, CellOptions, ColumnConfig, ColumnKey };