Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-sheet

Package Overview
Dependencies
Maintainers
0
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-sheet - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

lib/abstract-sheet-exporters/_style.d.ts

5

lib/abstract-sheet-exporters/_xlsx-sheet.d.ts
import * as XLSX from "xlsx-js-style";
import { Style, Sheet } from "../abstract-sheet/abstract-sheet";
export declare function xlsxWorkSheet(s: Sheet, styles: Record<string, any>): XLSX.WorkSheet;
export declare function createStyle(style: Style): any;
import { Sheet } from "../abstract-sheet/abstract-sheet";
export declare function xlsxWorkSheet(sheet: Sheet, styles: Record<string, any>): XLSX.WorkSheet;
//# sourceMappingURL=_xlsx-sheet.d.ts.map

130

lib/abstract-sheet-exporters/_xlsx-sheet.js

@@ -26,10 +26,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createStyle = exports.xlsxWorkSheet = void 0;
exports.xlsxWorkSheet = void 0;
const XLSX = __importStar(require("xlsx-js-style"));
function xlsxWorkSheet(s, styles) {
function xlsxWorkSheet(sheet, styles) {
var _a, _b;
let colMax = -1;
const cells = {};
for (let ri = 0; ri < s.rows.length; ri++) {
const r = s.rows[ri];
for (let ri = 0; ri < sheet.cells.length; ri++) {
const r = sheet.cells[ri];
colMax = Math.max(r.length, colMax);

@@ -44,12 +44,19 @@ for (let ci = 0; ci < r.length; ci++) {

}
cells[`${XLSX.utils.encode_col(ci)}${ri + 1}`] = { v: c.value, t: columnType(c.type), s };
const key = sheet.direction === "col" ? `${XLSX.utils.encode_col(ri)}${ci + 1}` : `${XLSX.utils.encode_col(ci)}${ri + 1}`;
cells[key] = { v: c.value, t: cellObject(c.type), s };
}
}
return Object.assign({ "!type": "sheet", "!ref": `A1:${XLSX.utils.encode_col(colMax)}${s.rows.length}`, "!cols": (_a = s.colInfo) === null || _a === void 0 ? void 0 : _a.map((i) => ({ wpx: i.widthPixels, hidden: i.hidden })), "!rows": (_b = s.rowInfo) === null || _b === void 0 ? void 0 : _b.map((i) => ({ hpx: i.heightPixels, hidden: i.hidden })) }, cells);
return Object.assign({ "!type": "sheet", "!ref": `A1:${sheet.direction === "col"
? `${XLSX.utils.encode_col(sheet.cells.length)}${colMax}`
: `${XLSX.utils.encode_col(colMax)}${sheet.cells.length}`}`, "!cols": (_a = sheet.colInfo) === null || _a === void 0 ? void 0 : _a.map((i) => { var _a; return ({ wpx: (_a = i.widthPixels) !== null && _a !== void 0 ? _a : 64, hidden: i.hidden }); }), "!rows": (_b = sheet.rowInfo) === null || _b === void 0 ? void 0 : _b.map((i) => { var _a; return ({ hpx: (_a = i.heightPixels) !== null && _a !== void 0 ? _a : 15, hidden: i.hidden }); }) }, cells);
}
exports.xlsxWorkSheet = xlsxWorkSheet;
const columnType = (colType) => {
const cellObject = (colType) => {
switch (colType) {
case "number":
return "n";
case "boolean":
return "b";
case "date":
return "d";
case undefined:

@@ -64,111 +71,2 @@ case "string":

const exhaustiveCheck = (check) => check;
function createStyle(style) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
let s = {};
if (style.vertical || style.horizontal || style.wrapText !== undefined || style.textRotation !== undefined) {
s.alignment = {};
if (style.vertical) {
s.alignment.vertical = style.vertical;
}
if (style.horizontal) {
s.alignment.horizontal = style.horizontal;
}
if (style.wrapText !== undefined) {
s.alignment.wrapText = style.wrapText;
}
if (style.textRotation !== undefined) {
s.alignment.textRotation = style.textRotation;
}
}
if (style.fillType || style.foreground || style.background) {
s.fill = {};
if (style.fillType) {
s.fill.patternType = style.fillType;
}
if (style.foreground) {
s.fill.fgColor = { rgb: style.foreground };
}
if (style.background) {
s.fill.bgColor = { rgb: style.background };
}
}
if (style.borderStyle || style.borderColor) {
s.border = {};
if (((_a = style.borderStyle) === null || _a === void 0 ? void 0 : _a.top) || ((_b = style.borderColor) === null || _b === void 0 ? void 0 : _b.top)) {
s.border.top = {};
}
if ((_c = style.borderStyle) === null || _c === void 0 ? void 0 : _c.top) {
s.border.top.style = style.borderStyle.top;
}
if ((_d = style.borderColor) === null || _d === void 0 ? void 0 : _d.top) {
s.border.top.color = { rgb: style.borderColor.top };
}
if (((_e = style.borderStyle) === null || _e === void 0 ? void 0 : _e.right) || ((_f = style.borderColor) === null || _f === void 0 ? void 0 : _f.right)) {
s.border.right = {};
}
if ((_g = style.borderStyle) === null || _g === void 0 ? void 0 : _g.right) {
s.border.right.style = style.borderStyle.right;
}
if ((_h = style.borderColor) === null || _h === void 0 ? void 0 : _h.right) {
s.border.right.color = { rgb: style.borderColor.right };
}
if (((_j = style.borderStyle) === null || _j === void 0 ? void 0 : _j.bottom) || ((_k = style.borderColor) === null || _k === void 0 ? void 0 : _k.bottom)) {
s.border.bottom = {};
}
if ((_l = style.borderStyle) === null || _l === void 0 ? void 0 : _l.bottom) {
s.border.bottom.style = style.borderStyle.bottom;
}
if ((_m = style.borderColor) === null || _m === void 0 ? void 0 : _m.bottom) {
s.border.bottom.color = { rgb: style.borderColor.bottom };
}
if (((_o = style.borderStyle) === null || _o === void 0 ? void 0 : _o.left) || ((_p = style.borderColor) === null || _p === void 0 ? void 0 : _p.left)) {
s.border.left = {};
}
if ((_q = style.borderStyle) === null || _q === void 0 ? void 0 : _q.left) {
s.border.left.style = style.borderStyle.left;
}
if ((_r = style.borderColor) === null || _r === void 0 ? void 0 : _r.left) {
s.border.left.color = { rgb: style.borderColor.left };
}
}
if (style.bold !== undefined ||
style.color ||
style.italic !== undefined ||
style.font ||
style.strike !== undefined ||
style.size !== undefined ||
style.underline !== undefined ||
style.script) {
s.font = {};
if (style.bold !== undefined) {
s.font.bold = style.bold;
}
if (style.color) {
s.font.color = { rgb: style.color };
}
if (style.italic !== undefined) {
s.font.italic = style.italic;
}
if (style.font) {
s.font.name = style.font;
}
if (style.strike !== undefined) {
s.font.strike = style.strike;
}
if (style.size !== undefined) {
s.font.sz = style.size;
}
if (style.underline !== undefined) {
s.font.underline = style.underline;
}
if (style.script !== undefined) {
s.font.vertAlign = style.script;
}
}
if (style.numberFormat !== undefined) {
s.font.numFmt = style.numberFormat;
}
return s;
}
exports.createStyle = createStyle;
//# sourceMappingURL=_xlsx-sheet.js.map

@@ -29,5 +29,6 @@ "use strict";

const _xlsx_sheet_1 = require("./_xlsx-sheet");
const _style_1 = require("./_style");
function toCsv(as, options) {
var _a, _b;
const styles = Object.fromEntries((_b = (_a = as.styles) === null || _a === void 0 ? void 0 : _a.map((s) => [s.name, (0, _xlsx_sheet_1.createStyle)(s)])) !== null && _b !== void 0 ? _b : []);
const styles = Object.fromEntries((_b = (_a = as.styles) === null || _a === void 0 ? void 0 : _a.map((s) => [s.name, (0, _style_1.createStyle)(s)])) !== null && _b !== void 0 ? _b : []);
const mappedOptions = options

@@ -34,0 +35,0 @@ ? {

export * from "./csv";
export * from "./xlsx";
export * from "./react";
//# sourceMappingURL=index.d.ts.map

@@ -19,2 +19,3 @@ "use strict";

__exportStar(require("./xlsx"), exports);
__exportStar(require("./react"), exports);
//# sourceMappingURL=index.js.map

@@ -29,2 +29,3 @@ "use strict";

const _xlsx_sheet_1 = require("./_xlsx-sheet");
const _style_1 = require("./_style");
function toXlsx(as) {

@@ -34,3 +35,3 @@ var _a, _b;

const sheetNames = Array();
const styles = Object.fromEntries((_b = (_a = as.styles) === null || _a === void 0 ? void 0 : _a.map((s) => [s.name, (0, _xlsx_sheet_1.createStyle)(s)])) !== null && _b !== void 0 ? _b : []);
const styles = Object.fromEntries((_b = (_a = as.styles) === null || _a === void 0 ? void 0 : _a.map((s) => [s.name, (0, _style_1.createStyle)(s)])) !== null && _b !== void 0 ? _b : []);
for (const s of as.sheets) {

@@ -37,0 +38,0 @@ sheetNames.push(s.name);

@@ -0,4 +1,6 @@

import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { XmlElement } from "./mustache-xml";
export declare function abstractSheetXml(el: XmlElement): unknown;
export declare const abstractSheetXml: (template: string, data: any, partials: Record<string, string>) => AbstractSheet;
export declare function abstractSheetOfXml(el: XmlElement): unknown;
export declare const parsedXsd: readonly XmlElement[];
//# sourceMappingURL=abstract-sheet-xml.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsedXsd = exports.abstractSheetXml = void 0;
exports.parsedXsd = exports.abstractSheetOfXml = exports.abstractSheetXml = void 0;
const abstract_sheet_1 = require("../abstract-sheet/abstract-sheet");
const abstract_sheet_xsd_1 = require("../abstract-sheet/abstract-sheet-xsd");
const mustache_xml_1 = require("./mustache-xml");
function abstractSheetXml(el) {
var _a, _b, _c, _d, _e, _f, _g, _h;
const abstractSheetXml = (template, data, partials) => abstractSheetOfXml((0, mustache_xml_1.parseMustacheXml)(template, data, partials)[0]);
exports.abstractSheetXml = abstractSheetXml;
function abstractSheetOfXml(el) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
const children = Array();

@@ -13,3 +15,3 @@ const childElements = Array();

if (child.tagName !== undefined) {
children.push(abstractSheetXml(child));
children.push(abstractSheetOfXml(child));
childElements.push(child);

@@ -21,6 +23,6 @@ }

let styles = undefined;
let sheets = [];
const sheets = [];
childElements.forEach((childEl, i) => {
if (childEl.tagName === "Sheets") {
sheets = children[i];
if (childEl.tagName === "Sheet") {
sheets.push(children[i]);
}

@@ -32,6 +34,4 @@ else if (childEl.tagName === "Styles") {

return { styles, sheets };
case "Sheets":
return children;
case "Sheet": {
let rows = [];
const cells = [];
let colInfo = undefined;

@@ -46,4 +46,4 @@ let rowInfo = undefined;

}
else if (childEl.tagName === "Rows") {
rows = children[i];
else if (childEl.tagName === "Cells") {
cells.push(children[i]);
}

@@ -53,5 +53,6 @@ });

name: ((_c = (_b = el.attributes) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : ""),
rows,
cells,
colInfo,
rowInfo,
direction: ((_e = (_d = el.attributes) === null || _d === void 0 ? void 0 : _d.direction) !== null && _e !== void 0 ? _e : ""),
};

@@ -67,8 +68,18 @@ }

return el.attributes;
case "Rows":
case "Cells":
return children;
case "Row":
return children;
case "Cell": {
return Object.assign(Object.assign({}, el.attributes), { styles: (_d = el.attributes.styles) === null || _d === void 0 ? void 0 : _d.split(",") });
const styles = (_f = el.attributes.styles) === null || _f === void 0 ? void 0 : _f.split(",");
if (el.attributes.number !== undefined) {
return Object.assign(Object.assign({}, el.attributes), { type: "number", value: el.attributes.number, styles });
}
else if (el.attributes.bool !== undefined) {
return Object.assign(Object.assign({}, el.attributes), { type: "boolean", value: el.attributes.boolean, styles });
}
else if (el.attributes.date !== undefined) {
return Object.assign(Object.assign({}, el.attributes), { type: "date", value: el.attributes.date, styles });
}
else {
return Object.assign(Object.assign({}, el.attributes), { type: "string", value: el.attributes.text, styles });
}
}

@@ -81,6 +92,6 @@ case "Styles":

const border = attributes.borderStyle.toString().split(" ");
const s0 = abstract_sheet_1.borderStyleRecord[(_e = border[0]) !== null && _e !== void 0 ? _e : ""];
const s1 = abstract_sheet_1.borderStyleRecord[(_f = border[1]) !== null && _f !== void 0 ? _f : ""];
const s2 = abstract_sheet_1.borderStyleRecord[(_g = border[2]) !== null && _g !== void 0 ? _g : ""];
const s3 = abstract_sheet_1.borderStyleRecord[(_h = border[3]) !== null && _h !== void 0 ? _h : ""];
const s0 = abstract_sheet_1.borderStyleRecord[(_g = border[0]) !== null && _g !== void 0 ? _g : ""];
const s1 = abstract_sheet_1.borderStyleRecord[(_h = border[1]) !== null && _h !== void 0 ? _h : ""];
const s2 = abstract_sheet_1.borderStyleRecord[(_j = border[2]) !== null && _j !== void 0 ? _j : ""];
const s3 = abstract_sheet_1.borderStyleRecord[(_k = border[3]) !== null && _k !== void 0 ? _k : ""];
switch (border.length) {

@@ -127,4 +138,4 @@ default:

}
exports.abstractSheetXml = abstractSheetXml;
exports.abstractSheetOfXml = abstractSheetOfXml;
exports.parsedXsd = (0, mustache_xml_1.parseXsd)(abstract_sheet_xsd_1.xsd);
//# sourceMappingURL=abstract-sheet-xml.js.map

@@ -1,2 +0,2 @@

export declare const xsd = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n\n\t<xs:element name=\"AbstractSheet\">\n\t\t<xs:complexType>\n\t\t\t<xs:sequence>\n\t\t\t\t<xs:element name=\"Styles\" type=\"Styles\" minOccurs=\"0\" />\n\t\t\t\t<xs:element name=\"Sheets\" type=\"Sheets\" minOccurs=\"0\" />\n\t\t\t</xs:sequence>\n\t\t</xs:complexType>\n\t</xs:element>\n\n\n\t<xs:complexType name=\"Sheets\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Sheet\" type=\"Sheet\" minOccurs=\"0\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Sheet\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Rows\" type=\"Rows\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t\t<xs:element name=\"RowInfos\" type=\"RowInfos\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t\t<xs:element name=\"ColInfos\" type=\"ColInfos\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t</xs:sequence>\n\t\t<xs:attribute name=\"name\" type=\"xs:string\" use=\"required\" />\n\t</xs:complexType>\n\n\t<xs:complexType name=\"ColInfos\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"ColInfo\" type=\"ColInfo\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"ColInfo\">\n\t\t<xs:attribute name=\"hidden\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"widthPixels\" type=\"xs:integer\" />\n\t</xs:complexType>\n\n\t<xs:complexType name=\"RowInfos\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"RowInfo\" type=\"RowInfo\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"RowInfo\">\n\t\t<xs:attribute name=\"hidden\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"heightPixels\" type=\"xs:integer\" />\n\t</xs:complexType>\n\n\n\t<xs:complexType name=\"Rows\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Row\" type=\"Row\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Row\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Cell\" type=\"Cell\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Cell\">\n\t\t<xs:attribute name=\"value\" type=\"NumberOrString\" use=\"required\" />\n\t\t<xs:attribute name=\"styles\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"type\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"string\" />\n\t\t\t\t\t<xs:enumeration value=\"number\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t</xs:complexType>\n\n\t<xs:simpleType name=\"NumberOrString\">\n\t\t<xs:union>\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:double\" />\n\t\t\t</xs:simpleType>\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\" />\n\t\t\t</xs:simpleType>\n\t\t</xs:union>\n\t</xs:simpleType>\n\n\t<xs:complexType name=\"Styles\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Style\" minOccurs=\"0\" maxOccurs=\"unbounded\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Style\">\n\t\t<xs:attribute name=\"name\" type=\"xs:string\" use=\"required\" />\n\t\t<xs:attribute name=\"vertical\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"top\" />\n\t\t\t\t\t<xs:enumeration value=\"center\" />\n\t\t\t\t\t<xs:enumeration value=\"bottom\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"horizontal\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"left\" />\n\t\t\t\t\t<xs:enumeration value=\"center\" />\n\t\t\t\t\t<xs:enumeration value=\"right\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"wrapText\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"textRotation\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"borderStyle\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"borderColor\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"fillType\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"solid\" />\n\t\t\t\t\t<xs:enumeration value=\"none\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"foreground\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"background\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"bold\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"color\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"italic\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"font\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"strike\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"size\" type=\"xs:double\" />\n\t\t<xs:attribute name=\"underline\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"script\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"superscript\" />\n\t\t\t\t\t<xs:enumeration value=\"subscript\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"numberFormat\" type=\"xs:string\" />\n\t</xs:complexType>\n\n</xs:schema>";
export declare const xsd = "<?xml version=\"1.1\" encoding=\"UTF-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n\n\t<xs:element name=\"AbstractSheet\">\n\t\t<xs:complexType>\n\t\t\t<xs:sequence>\n\t\t\t\t<xs:element name=\"Styles\" type=\"Styles\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t\t\t<xs:element name=\"Sheet\" type=\"Sheet\" />\n\t\t\t</xs:sequence>\n\t\t</xs:complexType>\n\t</xs:element>\n\n\t<xs:complexType name=\"Sheet\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Cells\" type=\"Cells\" />\n\t\t\t<xs:element name=\"RowInfos\" type=\"RowInfos\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t\t<xs:element name=\"ColInfos\" type=\"ColInfos\" minOccurs=\"0\" maxOccurs=\"1\" />\n\t\t</xs:sequence>\n\t\t<xs:attribute name=\"name\" type=\"xs:string\" use=\"required\" />\n\t\t<xs:attribute name=\"direction\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"row\" />\n\t\t\t\t\t<xs:enumeration value=\"col\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"ColInfos\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"ColInfo\" type=\"ColInfo\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"ColInfo\">\n\t\t<xs:attribute name=\"hidden\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"widthPixels\" type=\"xs:integer\" />\n\t</xs:complexType>\n\n\t<xs:complexType name=\"RowInfos\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"RowInfo\" type=\"RowInfo\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"RowInfo\">\n\t\t<xs:attribute name=\"hidden\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"heightPixels\" type=\"xs:integer\" />\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Cells\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Cell\" type=\"Cell\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Cell\">\n\t\t<xs:attribute name=\"number\" type=\"xs:string\" use=\"optional\" />\n\t\t<xs:attribute name=\"text\" type=\"xs:string\" use=\"optional\" />\n\t\t<xs:attribute name=\"bool\" type=\"xs:string\" use=\"optional\" />\n\t\t<xs:attribute name=\"date\" type=\"xs:string\" use=\"optional\" />\n\t\t<xs:attribute name=\"styles\" type=\"xs:string\" />\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Styles\">\n\t\t<xs:sequence>\n\t\t\t<xs:element name=\"Style\" minOccurs=\"0\" maxOccurs=\"unbounded\" />\n\t\t</xs:sequence>\n\t</xs:complexType>\n\n\t<xs:complexType name=\"Style\">\n\t\t<xs:attribute name=\"name\" type=\"xs:string\" use=\"required\" />\n\t\t<xs:attribute name=\"vertical\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"top\" />\n\t\t\t\t\t<xs:enumeration value=\"center\" />\n\t\t\t\t\t<xs:enumeration value=\"bottom\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"horizontal\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"left\" />\n\t\t\t\t\t<xs:enumeration value=\"center\" />\n\t\t\t\t\t<xs:enumeration value=\"right\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"wrapText\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"textRotation\" type=\"xs:double\" />\n\t\t<xs:attribute name=\"borderStyle\" type=\"BorderStyle\" />\n\t\t<xs:attribute name=\"borderColor\" type=\"BorderColor\" />\n\t\t<xs:attribute name=\"fillType\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"solid\" />\n\t\t\t\t\t<xs:enumeration value=\"none\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"foreground\" type=\"HexColorWithOpacity\" />\n\t\t<xs:attribute name=\"background\" type=\"HexColorWithOpacity\" />\n\t\t<xs:attribute name=\"bold\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"color\" type=\"HexColorWithOpacity\" />\n\t\t<xs:attribute name=\"italic\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"font\" type=\"xs:string\" />\n\t\t<xs:attribute name=\"strike\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"size\" type=\"xs:double\" />\n\t\t<xs:attribute name=\"underline\" type=\"xs:boolean\" />\n\t\t<xs:attribute name=\"script\">\n\t\t\t<xs:simpleType>\n\t\t\t\t<xs:restriction base=\"xs:string\">\n\t\t\t\t\t<xs:enumeration value=\"superscript\" />\n\t\t\t\t\t<xs:enumeration value=\"subscript\" />\n\t\t\t\t</xs:restriction>\n\t\t\t</xs:simpleType>\n\t\t</xs:attribute>\n\t\t<xs:attribute name=\"numberFormat\" type=\"xs:string\" />\n\t</xs:complexType>\n\n\t<xs:simpleType name=\"HexColorWithOpacity\">\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:pattern value=\"#[0-9a-fA-F]{8}\" />\n\t\t</xs:restriction>\n\t</xs:simpleType>\n\n\t<xs:simpleType name=\"BorderColor\">\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:pattern value=\"^#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})(\\s#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})){0,3}$\" />\n\t\t</xs:restriction>\n\t</xs:simpleType>\n\n\t<xs:simpleType name=\"BorderStyle\">\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:pattern value=\"^(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)(\\s(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)){0,3}$\" />\n\t\t</xs:restriction>\n\t</xs:simpleType>\n\n</xs:schema>";
//# sourceMappingURL=abstract-sheet-xsd.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.xsd = void 0;
exports.xsd = `<?xml version="1.0" encoding="UTF-8"?>
exports.xsd = `<?xml version="1.1" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

@@ -10,4 +10,4 @@

<xs:sequence>
<xs:element name="Styles" type="Styles" minOccurs="0" />
<xs:element name="Sheets" type="Sheets" minOccurs="0" />
<xs:element name="Styles" type="Styles" minOccurs="0" maxOccurs="1" />
<xs:element name="Sheet" type="Sheet" />
</xs:sequence>

@@ -17,12 +17,5 @@ </xs:complexType>

<xs:complexType name="Sheets">
<xs:sequence>
<xs:element name="Sheet" type="Sheet" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Sheet">
<xs:sequence>
<xs:element name="Rows" type="Rows" minOccurs="0" maxOccurs="1" />
<xs:element name="Cells" type="Cells" />
<xs:element name="RowInfos" type="RowInfos" minOccurs="0" maxOccurs="1" />

@@ -32,2 +25,10 @@ <xs:element name="ColInfos" type="ColInfos" minOccurs="0" maxOccurs="1" />

<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="direction">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="row" />
<xs:enumeration value="col" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>

@@ -57,11 +58,4 @@

<xs:complexType name="Rows">
<xs:complexType name="Cells">
<xs:sequence>
<xs:element name="Row" type="Row" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Row">
<xs:sequence>
<xs:element name="Cell" type="Cell" />

@@ -72,25 +66,9 @@ </xs:sequence>

<xs:complexType name="Cell">
<xs:attribute name="value" type="NumberOrString" use="required" />
<xs:attribute name="number" type="xs:string" use="optional" />
<xs:attribute name="text" type="xs:string" use="optional" />
<xs:attribute name="bool" type="xs:string" use="optional" />
<xs:attribute name="date" type="xs:string" use="optional" />
<xs:attribute name="styles" type="xs:string" />
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="string" />
<xs:enumeration value="number" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:simpleType name="NumberOrString">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:double" />
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="Styles">

@@ -123,5 +101,5 @@ <xs:sequence>

<xs:attribute name="wrapText" type="xs:boolean" />
<xs:attribute name="textRotation" type="xs:boolean" />
<xs:attribute name="borderStyle" type="xs:string" />
<xs:attribute name="borderColor" type="xs:string" />
<xs:attribute name="textRotation" type="xs:double" />
<xs:attribute name="borderStyle" type="BorderStyle" />
<xs:attribute name="borderColor" type="BorderColor" />
<xs:attribute name="fillType">

@@ -135,6 +113,6 @@ <xs:simpleType>

</xs:attribute>
<xs:attribute name="foreground" type="xs:string" />
<xs:attribute name="background" type="xs:string" />
<xs:attribute name="foreground" type="HexColorWithOpacity" />
<xs:attribute name="background" type="HexColorWithOpacity" />
<xs:attribute name="bold" type="xs:boolean" />
<xs:attribute name="color" type="xs:string" />
<xs:attribute name="color" type="HexColorWithOpacity" />
<xs:attribute name="italic" type="xs:boolean" />

@@ -156,3 +134,21 @@ <xs:attribute name="font" type="xs:string" />

<xs:simpleType name="HexColorWithOpacity">
<xs:restriction base="xs:string">
<xs:pattern value="#[0-9a-fA-F]{8}" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BorderColor">
<xs:restriction base="xs:string">
<xs:pattern value="^#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})(\\s#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})){0,3}$" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BorderStyle">
<xs:restriction base="xs:string">
<xs:pattern value="^(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)(\\s(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)){0,3}$" />
</xs:restriction>
</xs:simpleType>
</xs:schema>`;
//# sourceMappingURL=abstract-sheet-xsd.js.map
export type AbstractSheet = {
readonly sheets: Sheets;
readonly sheets: ReadonlyArray<Sheet>;
readonly styles?: Styles;
};
export type Sheets = ReadonlyArray<Sheet>;
export type Sheet = {
readonly name: string;
readonly rows: Rows;
readonly cells: ReadonlyArray<Cells>;
readonly colInfo?: ColInfos;
readonly rowInfo?: RowInfos;
readonly direction?: "row" | "col";
};

@@ -22,10 +22,23 @@ export type ColInfos = ReadonlyArray<ColInfo>;

};
export type Rows = ReadonlyArray<Row>;
export type Row = ReadonlyArray<Cell>;
export type Cell = {
readonly value: string | number;
export type Cells = ReadonlyArray<Cell>;
export type Cell = (NumberCell | TextCell | BoolCell | DateCell) & {
readonly styles?: ReadonlyArray<string>;
readonly type: CellType;
};
export type CellType = "string" | "number";
export type NumberCell = {
readonly type: "number";
readonly value: string | number | boolean | Date;
};
export type TextCell = {
readonly type: "string";
readonly value: string | number | boolean | Date;
};
export type BoolCell = {
readonly type: "boolean";
readonly value: string | number | boolean | Date;
};
export type DateCell = {
readonly type: "date";
readonly value: string | number | boolean | Date;
};
export type CellType = Cell["type"];
export type Styles = ReadonlyArray<Style>;

@@ -32,0 +45,0 @@ export type Style = {

{
"name": "abstract-sheet",
"version": "0.0.3",
"version": "0.0.4",
"description": "Abstract sheet",

@@ -20,2 +20,4 @@ "author": "Divid AB <info@divid.se>",

"mustache": "^4.2.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"ts-exhaustive-check": "^1.0.0",

@@ -26,5 +28,7 @@ "xlsx-js-style": "^1.2.0"

"@types/mustache": "^4.2.5",
"@types/react": "18.3.12",
"@types/react-dom": "^18.3.0",
"@types/xml": "^1.0.11"
},
"gitHead": "af67e376389d4ed86bd45b02ae384e95437f51df"
"gitHead": "80f37c857aa86d21d840cb162e69961923a5ab84"
}

@@ -7,2 +7,2 @@ # abstract-sheet

Abstract sheet with 3 renderers, xlsx, csv and json
Abstract sheet with 3 renderers, xlsx, csv and react.
import * as XLSX from "xlsx-js-style";
import { Style, CellType, Sheet } from "../abstract-sheet/abstract-sheet";
import { CellType, Sheet } from "../abstract-sheet/abstract-sheet";
export function xlsxWorkSheet(s: Sheet, styles: Record<string, any>): XLSX.WorkSheet {
export function xlsxWorkSheet(sheet: Sheet, styles: Record<string, any>): XLSX.WorkSheet {
let colMax = -1;
const cells: Record<string, XLSX.CellObject> = {};
for (let ri = 0; ri < s.rows.length; ri++) {
const r = s.rows[ri]!;
for (let ri = 0; ri < sheet.cells.length; ri++) {
const r = sheet.cells[ri]!;
colMax = Math.max(r.length, colMax);

@@ -18,3 +18,5 @@ for (let ci = 0; ci < r.length; ci++) {

}
cells[`${XLSX.utils.encode_col(ci)}${ri + 1}`] = { v: c.value, t: columnType(c.type), s };
const key =
sheet.direction === "col" ? `${XLSX.utils.encode_col(ri)}${ci + 1}` : `${XLSX.utils.encode_col(ci)}${ri + 1}`;
cells[key] = { v: c.value, t: cellObject(c.type), s };
}

@@ -25,5 +27,9 @@ }

"!type": "sheet",
"!ref": `A1:${XLSX.utils.encode_col(colMax)}${s.rows.length}`,
"!cols": s.colInfo?.map((i): XLSX.ColInfo => ({ wpx: i.widthPixels, hidden: i.hidden })),
"!rows": s.rowInfo?.map((i): XLSX.RowInfo => ({ hpx: i.heightPixels, hidden: i.hidden })),
"!ref": `A1:${
sheet.direction === "col"
? `${XLSX.utils.encode_col(sheet.cells.length)}${colMax}`
: `${XLSX.utils.encode_col(colMax)}${sheet.cells.length}`
}`,
"!cols": sheet.colInfo?.map((i): XLSX.ColInfo => ({ wpx: i.widthPixels ?? 64, hidden: i.hidden })),
"!rows": sheet.rowInfo?.map((i): XLSX.RowInfo => ({ hpx: i.heightPixels ?? 15, hidden: i.hidden })),
...cells,

@@ -33,6 +39,10 @@ };

const columnType = (colType: CellType | undefined): XLSX.CellObject["t"] => {
const cellObject = (colType: CellType | undefined): XLSX.CellObject["t"] => {
switch (colType) {
case "number":
return "n";
case "boolean":
return "b";
case "date":
return "d";
case undefined:

@@ -48,113 +58,1 @@ case "string":

const exhaustiveCheck = (check: never): never => check;
export function createStyle(style: Style): any {
let s: any = {};
if (style.vertical || style.horizontal || style.wrapText !== undefined || style.textRotation !== undefined) {
s.alignment = {};
if (style.vertical) {
s.alignment.vertical = style.vertical;
}
if (style.horizontal) {
s.alignment.horizontal = style.horizontal;
}
if (style.wrapText !== undefined) {
s.alignment.wrapText = style.wrapText;
}
if (style.textRotation !== undefined) {
s.alignment.textRotation = style.textRotation;
}
}
if (style.fillType || style.foreground || style.background) {
s.fill = {};
if (style.fillType) {
s.fill.patternType = style.fillType;
}
if (style.foreground) {
s.fill.fgColor = { rgb: style.foreground };
}
if (style.background) {
s.fill.bgColor = { rgb: style.background };
}
}
if (style.borderStyle || style.borderColor) {
s.border = {};
if (style.borderStyle?.top || style.borderColor?.top) {
s.border.top = {};
}
if (style.borderStyle?.top) {
s.border.top.style = style.borderStyle.top;
}
if (style.borderColor?.top) {
s.border.top.color = { rgb: style.borderColor.top };
}
if (style.borderStyle?.right || style.borderColor?.right) {
s.border.right = {};
}
if (style.borderStyle?.right) {
s.border.right.style = style.borderStyle.right;
}
if (style.borderColor?.right) {
s.border.right.color = { rgb: style.borderColor.right };
}
if (style.borderStyle?.bottom || style.borderColor?.bottom) {
s.border.bottom = {};
}
if (style.borderStyle?.bottom) {
s.border.bottom.style = style.borderStyle.bottom;
}
if (style.borderColor?.bottom) {
s.border.bottom.color = { rgb: style.borderColor.bottom };
}
if (style.borderStyle?.left || style.borderColor?.left) {
s.border.left = {};
}
if (style.borderStyle?.left) {
s.border.left.style = style.borderStyle.left;
}
if (style.borderColor?.left) {
s.border.left.color = { rgb: style.borderColor.left };
}
}
if (
style.bold !== undefined ||
style.color ||
style.italic !== undefined ||
style.font ||
style.strike !== undefined ||
style.size !== undefined ||
style.underline !== undefined ||
style.script
) {
s.font = {};
if (style.bold !== undefined) {
s.font.bold = style.bold;
}
if (style.color) {
s.font.color = { rgb: style.color };
}
if (style.italic !== undefined) {
s.font.italic = style.italic;
}
if (style.font) {
s.font.name = style.font;
}
if (style.strike !== undefined) {
s.font.strike = style.strike;
}
if (style.size !== undefined) {
s.font.sz = style.size;
}
if (style.underline !== undefined) {
s.font.underline = style.underline;
}
if (style.script !== undefined) {
s.font.vertAlign = style.script;
}
}
if (style.numberFormat !== undefined) {
s.font.numFmt = style.numberFormat;
}
return s;
}
import * as XLSX from "xlsx-js-style";
import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { createStyle, xlsxWorkSheet } from "./_xlsx-sheet";
import { xlsxWorkSheet } from "./_xlsx-sheet";
import { createStyle } from "./_style";

@@ -5,0 +6,0 @@ export type CsvFile = { readonly name: string; readonly csv: string };

export * from "./csv";
export * from "./xlsx";
export * from "./react";
import * as XLSX from "xlsx-js-style";
import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { createStyle, xlsxWorkSheet } from "./_xlsx-sheet";
import { xlsxWorkSheet } from "./_xlsx-sheet";
import { createStyle } from "./_style";

@@ -5,0 +6,0 @@ export function toXlsx(as: AbstractSheet): Buffer {

@@ -6,15 +6,17 @@ import {

ColInfos,
Row,
Cells,
RowInfo,
RowInfos,
Rows,
Sheet,
Sheets,
Style,
Styles,
AbstractSheet,
} from "../abstract-sheet/abstract-sheet";
import { xsd } from "../abstract-sheet/abstract-sheet-xsd";
import { parseXml, parseXsd, XmlElement } from "./mustache-xml";
import { parseMustacheXml, parseXsd, XmlElement } from "./mustache-xml";
export function abstractSheetXml(el: XmlElement): unknown {
export const abstractSheetXml = (template: string, data: any, partials: Record<string, string>): AbstractSheet =>
abstractSheetOfXml(parseMustacheXml(template, data, partials)[0]!) as AbstractSheet;
export function abstractSheetOfXml(el: XmlElement): unknown {
const children = Array<unknown>();

@@ -24,13 +26,14 @@ const childElements = Array<XmlElement>();

if (child.tagName !== undefined) {
children.push(abstractSheetXml(child));
children.push(abstractSheetOfXml(child));
childElements.push(child);
}
}
switch (el.tagName) {
case "AbstractSheet":
let styles: Styles | undefined = undefined;
let sheets: Sheets = [];
const sheets: Array<Sheet> = [];
childElements.forEach((childEl, i) => {
if (childEl.tagName === "Sheets") {
sheets = children[i] as Sheets;
if (childEl.tagName === "Sheet") {
sheets.push(children[i] as Sheet);
} else if (childEl.tagName === "Styles") {

@@ -40,7 +43,5 @@ styles = children[i] as Styles;

});
return { styles, sheets };
case "Sheets":
return children as Sheets;
return { styles, sheets } satisfies AbstractSheet;
case "Sheet": {
let rows: Rows = [];
const cells: Array<Cells> = [];
let colInfo: ColInfos | undefined = undefined;

@@ -53,4 +54,4 @@ let rowInfo: RowInfos | undefined = undefined;

rowInfo = children[i] as RowInfos;
} else if (childEl.tagName === "Rows") {
rows = children[i] as Rows;
} else if (childEl.tagName === "Cells") {
cells.push(children[i] as Cells);
}

@@ -60,6 +61,7 @@ });

name: ((el.attributes as Partial<Record<keyof Sheet, unknown>>)?.name ?? "") as string,
rows,
cells,
colInfo,
rowInfo,
};
direction: ((el.attributes as Partial<Record<keyof Sheet, unknown>>)?.direction ?? "") as Sheet["direction"],
} satisfies Sheet;
}

@@ -74,8 +76,15 @@ case "ColInfos":

return el.attributes as RowInfo;
case "Rows":
return children as Rows;
case "Row":
return children as Row;
case "Cells":
return children as Cells;
case "Cell": {
return { ...el.attributes, styles: el.attributes.styles?.split(",") } as Cell;
const styles = el.attributes.styles?.split(",");
if (el.attributes.number !== undefined) {
return { ...el.attributes, type: "number", value: el.attributes.number, styles } as Cell;
} else if (el.attributes.bool !== undefined) {
return { ...el.attributes, type: "boolean", value: el.attributes.boolean, styles } as Cell;
} else if (el.attributes.date !== undefined) {
return { ...el.attributes, type: "date", value: el.attributes.date, styles } as Cell;
} else {
return { ...el.attributes, type: "string", value: el.attributes.text, styles } as Cell;
}
}

@@ -82,0 +91,0 @@ case "Styles":

@@ -1,2 +0,2 @@

export const xsd = `<?xml version="1.0" encoding="UTF-8"?>
export const xsd = `<?xml version="1.1" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

@@ -7,4 +7,4 @@

<xs:sequence>
<xs:element name="Styles" type="Styles" minOccurs="0" />
<xs:element name="Sheets" type="Sheets" minOccurs="0" />
<xs:element name="Styles" type="Styles" minOccurs="0" maxOccurs="1" />
<xs:element name="Sheet" type="Sheet" />
</xs:sequence>

@@ -14,12 +14,5 @@ </xs:complexType>

<xs:complexType name="Sheets">
<xs:sequence>
<xs:element name="Sheet" type="Sheet" minOccurs="0" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Sheet">
<xs:sequence>
<xs:element name="Rows" type="Rows" minOccurs="0" maxOccurs="1" />
<xs:element name="Cells" type="Cells" />
<xs:element name="RowInfos" type="RowInfos" minOccurs="0" maxOccurs="1" />

@@ -29,2 +22,10 @@ <xs:element name="ColInfos" type="ColInfos" minOccurs="0" maxOccurs="1" />

<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="direction">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="row" />
<xs:enumeration value="col" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>

@@ -54,11 +55,4 @@

<xs:complexType name="Rows">
<xs:complexType name="Cells">
<xs:sequence>
<xs:element name="Row" type="Row" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Row">
<xs:sequence>
<xs:element name="Cell" type="Cell" />

@@ -69,25 +63,9 @@ </xs:sequence>

<xs:complexType name="Cell">
<xs:attribute name="value" type="NumberOrString" use="required" />
<xs:attribute name="number" type="xs:string" use="optional" />
<xs:attribute name="text" type="xs:string" use="optional" />
<xs:attribute name="bool" type="xs:string" use="optional" />
<xs:attribute name="date" type="xs:string" use="optional" />
<xs:attribute name="styles" type="xs:string" />
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="string" />
<xs:enumeration value="number" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:simpleType name="NumberOrString">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:double" />
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string" />
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="Styles">

@@ -120,5 +98,5 @@ <xs:sequence>

<xs:attribute name="wrapText" type="xs:boolean" />
<xs:attribute name="textRotation" type="xs:boolean" />
<xs:attribute name="borderStyle" type="xs:string" />
<xs:attribute name="borderColor" type="xs:string" />
<xs:attribute name="textRotation" type="xs:double" />
<xs:attribute name="borderStyle" type="BorderStyle" />
<xs:attribute name="borderColor" type="BorderColor" />
<xs:attribute name="fillType">

@@ -132,6 +110,6 @@ <xs:simpleType>

</xs:attribute>
<xs:attribute name="foreground" type="xs:string" />
<xs:attribute name="background" type="xs:string" />
<xs:attribute name="foreground" type="HexColorWithOpacity" />
<xs:attribute name="background" type="HexColorWithOpacity" />
<xs:attribute name="bold" type="xs:boolean" />
<xs:attribute name="color" type="xs:string" />
<xs:attribute name="color" type="HexColorWithOpacity" />
<xs:attribute name="italic" type="xs:boolean" />

@@ -153,2 +131,20 @@ <xs:attribute name="font" type="xs:string" />

<xs:simpleType name="HexColorWithOpacity">
<xs:restriction base="xs:string">
<xs:pattern value="#[0-9a-fA-F]{8}" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BorderColor">
<xs:restriction base="xs:string">
<xs:pattern value="^#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})(\\s#([0-9a-fA-F]{6}|[0-9a-fA-F]{8})){0,3}$" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="BorderStyle">
<xs:restriction base="xs:string">
<xs:pattern value="^(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)(\\s(dashDotDot|dashDot|dashed|dotted|hair|mediumDashDotDot|mediumDashDot|mediumDashed|medium|slantDashDot|thick|thin)){0,3}$" />
</xs:restriction>
</xs:simpleType>
</xs:schema>`;
export type AbstractSheet = {
readonly sheets: Sheets;
readonly sheets: ReadonlyArray<Sheet>;
readonly styles?: Styles;
};
export type Sheets = ReadonlyArray<Sheet>;
export type Sheet = {
readonly name: string;
readonly rows: Rows;
readonly cells: ReadonlyArray<Cells>;
readonly colInfo?: ColInfos;
readonly rowInfo?: RowInfos;
readonly direction?: "row" | "col";
};

@@ -23,13 +22,12 @@

export type Rows = ReadonlyArray<Row>;
export type Cells = ReadonlyArray<Cell>;
export type Row = ReadonlyArray<Cell>;
export type Cell = (NumberCell | TextCell | BoolCell | DateCell) & { readonly styles?: ReadonlyArray<string> };
export type Cell = {
readonly value: string | number;
readonly styles?: ReadonlyArray<string>;
readonly type: CellType;
};
export type NumberCell = { readonly type: "number"; readonly value: string | number | boolean | Date };
export type TextCell = { readonly type: "string"; readonly value: string | number | boolean | Date };
export type BoolCell = { readonly type: "boolean"; readonly value: string | number | boolean | Date };
export type DateCell = { readonly type: "date"; readonly value: string | number | boolean | Date };
export type CellType = "string" | "number";
export type CellType = Cell["type"];

@@ -36,0 +34,0 @@ export type Styles = ReadonlyArray<Style>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc