UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

36 lines 1.12 kB
/* eslint-disable no-empty-function */ import { EXTRA_FIELD, ORIGIN_FIELD, VALUE_FIELD } from '../common/constant'; export class CellData { constructor(raw, extraField) { this.raw = raw; this.extraField = extraField; } static getCellData(raw, extraField) { return new CellData(raw, extraField); } static getCellDataList(raw, extraFields) { return extraFields.map((field) => CellData.getCellData(raw, field)); } static getFieldValue(data, field = '') { if (data instanceof CellData) { return field ? data.getValueByField(field) : data[ORIGIN_FIELD]; } return data === null || data === void 0 ? void 0 : data[field]; } get [ORIGIN_FIELD]() { return this.raw; } get [EXTRA_FIELD]() { return this.extraField; } get [VALUE_FIELD]() { return this.raw[this.extraField]; } getValueByField(field) { if (field === VALUE_FIELD || field === EXTRA_FIELD) { return this[field]; } return this.raw[field]; } } //# sourceMappingURL=cell-data.js.map