You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gristlabs_grist-core/app/client/widgets/ErrorDom.ts

20 lines
895 B

import {DataRowModel} from 'app/client/models/DataRowModel';
import {ViewFieldRec} from 'app/client/models/entities/ViewFieldRec';
import {getObjCode} from 'app/common/gristTypes';
import {formatUnknown} from 'app/common/ValueFormatter';
import {dom} from 'grainjs';
export function buildErrorDom(row: DataRowModel, field: ViewFieldRec) {
const value = row.cells[field.colId.peek()];
const options = field.widgetOptionsJson;
// The "invalid" class sets the pink background, as long as the error text is non-empty.
return dom('div.field_clip.invalid',
// Sets CSS class field-error-P, field-error-U, etc.
dom.clsPrefix('field-error-', (use) => getObjCode(use(value)) || ''),
dom.style('text-align', options.prop('alignment')),
dom.cls('text_wrapping', (use) => Boolean(use(options.prop('wrap')))),
dom.text((use) => formatUnknown(value ? use(value) : '???'))
);
}