import { FiltersMap, KeyedItem, PickerState } from '@wix/bex-core'; import React, { ReactNode } from 'react'; import { Avatar, TableListItem, TableListItemColumn, Text, } from '@wix/design-system'; import { ChevronRightLarge } from '@wix/wix-ui-icons-common'; import { PickerListItemProps } from '../PickerListItemProps'; import { st, classes } from './PickerTableListItem.st.css.js'; export interface PickerTableListItemPropsBase extends Partial { primaryAction?: ReactNode; primaryActionWidth?: TableListItemColumn['width']; } export interface PickerTableListItemProps extends PickerTableListItemPropsBase { dataHook?: string; showDivider?: boolean; keyedItem: KeyedItem; state: PickerState; multiple?: boolean; } export function PickerTableListItem( props: PickerTableListItemProps, ) { const { dataHook, showDivider, keyedItem, state, primaryAction, primaryActionWidth = 'auto', title, subtitle, extraNode, disabled, checkbox, multiple, options: optionsProp = [], ...tableListItemProps } = props; const { collection } = state; const name = collection.itemName(keyedItem.item); const { start, end } = optionsProp.reduce( (prev, current) => { const column: TableListItemColumn = { value: undefined, ...current, }; if (current.end) { prev.end.push(column); } else { prev.start.push(column); } return prev; }, { start: [] as TableListItemColumn[], end: [] as TableListItemColumn[], }, ); if (!start.length) { start.push( { align: 'left' as const, width: '84px', value: , }, { align: 'left' as const, value: {name}, }, ); } const options: TableListItemColumn[] = [ ...start, { width: primaryActionWidth, value: primaryAction || , align: 'right', }, ...end, ]; return ( ); }