UNPKG

material-react-table

Version:

A fully featured Material UI V6 implementation of TanStack React Table V8, written from the ground up in TypeScript.

24 lines (21 loc) 598 B
import { type DropdownOption } from '../types'; export const parseFromValuesOrFunc = <T, U>( fn: ((arg: U) => T) | T | undefined, arg: U, ): T | undefined => (fn instanceof Function ? fn(arg) : fn); export const getValueAndLabel = ( option?: DropdownOption | null, ): { label: string; value: string } => { let label: string = ''; let value: string = ''; if (option) { if (typeof option !== 'object') { label = option; value = option; } else { label = option.label ?? option.value; value = option.value ?? label; } } return { label, value }; };