import {CellValue} from 'app/common/DocActions'; import * as gutil from 'app/common/gutil'; import * as gristTypes from 'app/common/gristTypes'; import {NumberFormatOptions} from 'app/common/NumberFormat'; import {FormatOptions, formatUnknown, IsRightTypeFunc} from 'app/common/ValueFormatter'; import {GristType} from 'app/plugin/GristData'; import {decodeObject} from 'app/plugin/objtypes'; import {Style} from 'exceljs'; import moment from 'moment-timezone'; interface WidgetOptions extends NumberFormatOptions { textColor?: 'string'; fillColor?: 'string'; alignment?: 'left' | 'center' | 'right'; dateFormat?: string; timeFormat?: string; } class BaseFormatter { protected isRightType: IsRightTypeFunc; protected widgetOptions: WidgetOptions; constructor(public type: string, public opts: FormatOptions) { this.isRightType = gristTypes.isRightType(gristTypes.extractTypeFromColType(type)) || gristTypes.isRightType('Any')!; this.widgetOptions = opts; } /** * Formats a value that matches the type of this formatter. This should be overridden by derived * classes to handle values in formatter-specific ways. */ public format(value: any): any { return value; } public style(): Partial