| 1 |
import { h } from 'vue' |
| 2 |
import IvyIcon from '@/views/_components/icon/IvyIcon.vue' |
| 3 |
import type { TableColumn } from '@/views/_components/table/IvyTableColumn' |
| 4 |
import { starCellRenderer } from '@/views/_components/table/renderers' |
| 5 |
import type { StarCellOptions } from '@/views/_components/table/renderers/starCellRenderer' |
| 6 |
|
| 7 |
export interface StarColumnOptions<Row extends Record<string, unknown>> { |
| 8 |
onChange: StarCellOptions<Row>['onChange'] |
| 9 |
field: StarCellOptions<Row>['field'] |
| 10 |
ariaLabel?: StarCellOptions<Row>['ariaLabel'] |
| 11 |
title?: string |
| 12 |
width?: number |
| 13 |
minWidth?: number |
| 14 |
headerColor?: string |
| 15 |
overrides?: Partial<TableColumn> |
| 16 |
} |
| 17 |
|
| 18 |
export function starColumn<Row extends Record<string, unknown>>( |
| 19 |
options: StarColumnOptions<Row>, |
| 20 |
): TableColumn { |
| 21 |
const width = options.width ?? 32 |
| 22 |
return { |
| 23 |
key: 'star', |
| 24 |
width, |
| 25 |
minWidth: options.minWidth ?? width, |
| 26 |
title: options.title, |
| 27 |
headerRenderer: () => |
| 28 |
h(IvyIcon, { |
| 29 |
name: 'star', |
| 30 |
type: 'outline', |
| 31 |
size: 'd', |
| 32 |
color: options.headerColor ?? 'var(--map-base-dusk-symbol-2)', |
| 33 |
}), |
| 34 |
cellRenderer: starCellRenderer<Row>({ |
| 35 |
onChange: options.onChange, |
| 36 |
field: options.field, |
| 37 |
ariaLabel: options.ariaLabel, |
| 38 |
}), |
| 39 |
visible: true, |
| 40 |
showInModal: true, |
| 41 |
...options.overrides, |
| 42 |
} |
| 43 |
} |
| 44 |
|