Skip to content

Instantly share code, notes, and snippets.

@masaeedu
Created January 21, 2021 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masaeedu/e001c6dd1e68d4a02305e88c8086f037 to your computer and use it in GitHub Desktop.
Save masaeedu/e001c6dd1e68d4a02305e88c8086f037 to your computer and use it in GitHub Desktop.
type AccessorAndId<D> =
| {accessor: keyof D}
| {id: string; accessor: AccessorFunction<D>}
export type Column<D = any> = Partial<Column.Basics> &
Partial<
Column.CellProps & Column.FilterProps & Column.FooterProps & Column.HeaderProps
> &
AccessorAndId<D> & {
/**
* Property name as string or Accessor
* @example: 'myProperty'
* @example ["a.b", "c"]
* @example ["a", "b", "c"]
* @example {"a": {"b": {"c": $}}}
* @example (row) => row.propertyName
*/
accessor?: Accessor<D>
/**
* Conditional - A unique ID is required if the accessor is not a string or if you would like to override the column name used in server-side calls
* @example 'myProperty'
*/
id?: string
/**
* No description
* @example (values, rows) => _.round(_.mean(values))
* @example (values, rows) => _.sum(values)
*/
aggregate?: Aggregator
/**
* Default: undefined - A hardcoded width for the column. This overrides both min and max width options
*/
width?: number
/**
* Default: undefined - A maximum width for this column.
* @default undefined
*/
maxWidth?: number
/**
* Turns this column into a special column for specifying expander and pivot column options.
* If this option is true and there is NOT a pivot column, the `expanderDefaults` options will be applied on top of the column options.
* If this option is true and there IS a pivot column, the `pivotDefaults` options will be applied on top of the column options.
* Adding a column with the `expander` option set will allow you to rearrange expander and pivot column orderings in the table.
* It will also let you specify rendering of the header (and header group if this special column is placed in the `columns` option of another column) and the rendering of the expander itself.
*/
expander?: boolean
/** Header Groups only */
columns?: Array<Column<D>>
/**
* Turns this column into a special column for specifying pivot position in your column definitions.
* The `pivotDefaults` options will be applied on top of this column's options.
* It will also let you specify rendering of the header (and header group if this special column is placed in the `columns` option of another column)
*/
pivot?: boolean
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment