UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

40 lines 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CellData = void 0; /* eslint-disable no-empty-function */ const constant_1 = require("../common/constant"); 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[constant_1.ORIGIN_FIELD]; } return data === null || data === void 0 ? void 0 : data[field]; } get [constant_1.ORIGIN_FIELD]() { return this.raw; } get [constant_1.EXTRA_FIELD]() { return this.extraField; } get [constant_1.VALUE_FIELD]() { return this.raw[this.extraField]; } getValueByField(field) { if (field === constant_1.VALUE_FIELD || field === constant_1.EXTRA_FIELD) { return this[field]; } return this.raw[field]; } } exports.CellData = CellData; //# sourceMappingURL=cell-data.js.map