import { Component, Vnode } from 'mithril' import { ComponentAttrs } from '../../types' /** * `ComponentAttrs`'s own `key` (Mithril's vnode key, a string or a number) is * omitted on purpose: below, `key` is the DEPRECATED alias of `itemKey` and * takes a function, which is incompatible with the vnode key. Extending the * interface directly is a type error ("incorrectly extends ComponentAttrs") * that `skipLibCheck` hides, so consumers inheriting ListAttrs would hit it. */ export interface ListAttrs extends Omit { /** * Data array. When passed, the row template is repeated per item * (data-driven mode). Without `data`, the explicit children are used * (`ListRow`/`ListCol`). */ data?: readonly T[] /** * Row template: `(item, index) => vnode`. It repeats `data.length` times. * Required when `data` is passed (alternative: a single child function). */ render?: (item: T, index: number) => Vnode | null /** * Row key accessor for Mithril diffing when * resizing/reordering: `(item, index) => string | number`. Default: * index. It is also used as the signature of `sortable` mode (it recreates the * SortableJS instance when the set of keys changes). */ itemKey?: (item: T, index: number) => string | number /** * @deprecated Alias of `itemKey`, kept for compatibility. In Mithril * `key` IS the vnode key: using it here pushes List's `