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

abstract-sheet

Package Overview
Dependencies
Maintainers
1
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.8 to 0.0.9

2

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

@@ -1,3 +0,3 @@

import { Style } from "../abstract-sheet/abstract-sheet";
import { Style } from "../abstract-sheet/abstract-sheet.js";
export declare function createStyle(style: Style): any;
//# sourceMappingURL=_style.d.ts.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createStyle = createStyle;
function createStyle(style) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
export function createStyle(style) {
let s = {};

@@ -36,36 +32,36 @@ if (style.vertical || style.horizontal || style.wrapText !== undefined || style.textRotation !== undefined) {

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)) {
if (style.borderStyle?.top || style.borderColor?.top) {
s.border.top = {};
}
if ((_c = style.borderStyle) === null || _c === void 0 ? void 0 : _c.top) {
if (style.borderStyle?.top) {
s.border.top.style = style.borderStyle.top;
}
if ((_d = style.borderColor) === null || _d === void 0 ? void 0 : _d.top) {
if (style.borderColor?.top) {
s.border.top.color = { rgb: style.borderColor.top.slice(1) };
}
if (((_e = style.borderStyle) === null || _e === void 0 ? void 0 : _e.right) || ((_f = style.borderColor) === null || _f === void 0 ? void 0 : _f.right)) {
if (style.borderStyle?.right || style.borderColor?.right) {
s.border.right = {};
}
if ((_g = style.borderStyle) === null || _g === void 0 ? void 0 : _g.right) {
if (style.borderStyle?.right) {
s.border.right.style = style.borderStyle.right;
}
if ((_h = style.borderColor) === null || _h === void 0 ? void 0 : _h.right) {
if (style.borderColor?.right) {
s.border.right.color = { rgb: style.borderColor.right.slice(1) };
}
if (((_j = style.borderStyle) === null || _j === void 0 ? void 0 : _j.bottom) || ((_k = style.borderColor) === null || _k === void 0 ? void 0 : _k.bottom)) {
if (style.borderStyle?.bottom || style.borderColor?.bottom) {
s.border.bottom = {};
}
if ((_l = style.borderStyle) === null || _l === void 0 ? void 0 : _l.bottom) {
if (style.borderStyle?.bottom) {
s.border.bottom.style = style.borderStyle.bottom;
}
if ((_m = style.borderColor) === null || _m === void 0 ? void 0 : _m.bottom) {
if (style.borderColor?.bottom) {
s.border.bottom.color = { rgb: style.borderColor.bottom.slice(1) };
}
if (((_o = style.borderStyle) === null || _o === void 0 ? void 0 : _o.left) || ((_p = style.borderColor) === null || _p === void 0 ? void 0 : _p.left)) {
if (style.borderStyle?.left || style.borderColor?.left) {
s.border.left = {};
}
if ((_q = style.borderStyle) === null || _q === void 0 ? void 0 : _q.left) {
if (style.borderStyle?.left) {
s.border.left.style = style.borderStyle.left;
}
if ((_r = style.borderColor) === null || _r === void 0 ? void 0 : _r.left) {
if (style.borderColor?.left) {
s.border.left.color = { rgb: style.borderColor.left.slice(1) };

@@ -72,0 +68,0 @@ }

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

@@ -1,40 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.xlsxWorkSheet = xlsxWorkSheet;
const XLSX = __importStar(require("xlsx-js-style"));
function xlsxWorkSheet(sheet, styles) {
var _a, _b;
import * as XLSX from "xlsx-js-style";
export function xlsxWorkSheet(sheet, styles) {
let colMax = -1;

@@ -50,3 +13,3 @@ const cells = {};

for (const style of c.styles) {
s = Object.assign(Object.assign({}, s), styles[style]);
s = { ...s, ...styles[style] };
}

@@ -58,5 +21,11 @@ }

}
return Object.assign({ "!type": "sheet", "!ref": `A1:${sheet.direction === "col"
return {
"!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);
: `${XLSX.utils.encode_col(colMax)}${sheet.cells.length}`}`,
"!cols": sheet.colInfo?.map((i) => ({ wpx: i.widthPixels ?? 64, hidden: i.hidden })),
"!rows": sheet.rowInfo?.map((i) => ({ hpx: i.heightPixels ?? 15, hidden: i.hidden })),
...cells,
};
}

@@ -63,0 +32,0 @@ const cellObject = (colType) => {

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

import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";
export type CsvFile = {

@@ -3,0 +3,0 @@ readonly name: string;

@@ -1,44 +0,7 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.toCsv = toCsv;
const XLSX = __importStar(require("xlsx-js-style"));
const _xlsx_sheet_1 = require("./_xlsx-sheet");
const _style_1 = require("./_style");
function toCsv(abstractSheets, options) {
import * as XLSX from "xlsx-js-style";
import { xlsxWorkSheet } from "./_xlsx-sheet.js";
import { createStyle } from "./_style.js";
export function toCsv(abstractSheets, options) {
return abstractSheets.map((as) => {
var _a, _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 styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
const mappedOptions = options

@@ -56,5 +19,5 @@ ? {

: undefined;
return as.sheets.map((s) => ({ name: s.name, csv: XLSX.utils.sheet_to_csv((0, _xlsx_sheet_1.xlsxWorkSheet)(s, styles), mappedOptions) }));
return as.sheets.map((s) => ({ name: s.name, csv: XLSX.utils.sheet_to_csv(xlsxWorkSheet(s, styles), mappedOptions) }));
});
}
//# sourceMappingURL=csv.js.map

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

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

@@ -1,20 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./csv"), exports);
__exportStar(require("./xlsx"), exports);
__exportStar(require("./react"), exports);
export * from "./csv.js";
export * from "./xlsx.js";
export * from "./react.js";
//# sourceMappingURL=index.js.map

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

import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";
export declare function toReact({ abstractSheet }: {

@@ -3,0 +3,0 @@ readonly abstractSheet: AbstractSheet;

@@ -1,14 +0,8 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.toReact = toReact;
const react_1 = __importDefault(require("react"));
function toReact({ abstractSheet }) {
const styles = react_1.default.useMemo(() => { var _a, _b; return Object.fromEntries((_b = (_a = abstractSheet.styles) === null || _a === void 0 ? void 0 : _a.map((s) => [s.name, s])) !== null && _b !== void 0 ? _b : []); }, [abstractSheet.styles]);
return (react_1.default.createElement("div", { className: "abstract-sheet", style: { display: "flex", flexDirection: "column", gap: "0.2rem" } }, abstractSheet.sheets.map((s, si) => {
import React from "react";
export function toReact({ abstractSheet }) {
const styles = React.useMemo(() => Object.fromEntries(abstractSheet.styles?.map((s) => [s.name, s]) ?? []), [abstractSheet.styles]);
return (React.createElement("div", { className: "abstract-sheet", style: { display: "flex", flexDirection: "column", gap: "0.2rem" } }, abstractSheet.sheets.map((s, si) => {
const maxCols = s.cells.reduce((a, c) => Math.max(a, c.length), 0);
const colArray = Array.from({ length: maxCols }, (_, i) => i);
return (react_1.default.createElement("div", { className: `sheet sheet-${si} sheet-${s.name}`, key: s.name, style: {
return (React.createElement("div", { className: `sheet sheet-${si} sheet-${s.name}`, key: s.name, style: {
display: "grid",

@@ -20,7 +14,6 @@ width: "max-content",

.map((_, ri) => {
var _a;
const info = (_a = s.rowInfo) === null || _a === void 0 ? void 0 : _a[ri];
return (info === null || info === void 0 ? void 0 : info.hidden)
const info = s.rowInfo?.[ri];
return info?.hidden
? ""
: (info === null || info === void 0 ? void 0 : info.heightPixels) !== undefined
: info?.heightPixels !== undefined
? `${info.heightPixels}px`

@@ -32,7 +25,6 @@ : "minmax(18px, max-content)";

.map((_, ci) => {
var _a;
const co = (_a = s.colInfo) === null || _a === void 0 ? void 0 : _a[ci];
return (co === null || co === void 0 ? void 0 : co.hidden)
const co = s.colInfo?.[ci];
return co?.hidden
? ""
: (co === null || co === void 0 ? void 0 : co.widthPixels) !== undefined
: co?.widthPixels !== undefined
? `${co.widthPixels}px`

@@ -42,14 +34,16 @@ : "minmax(64px, max-content)";

.join(" ")}`,
} }, s.cells.map((cells, cellsIdx) => (react_1.default.createElement("div", { key: cellsIdx, className: `cells cells-${cellsIdx}`, style: Object.assign({ display: "grid" }, (s.direction === "col"
? { gridTemplateRows: `subgrid`, gridRow: "1 / -1" }
: { gridTemplateColumns: `subgrid`, gridColumn: "1 / -1" })) }, Array.from({ length: maxCols }, (_, i) => i).map((ci) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
} }, s.cells.map((cells, cellsIdx) => (React.createElement("div", { key: cellsIdx, className: `cells cells-${cellsIdx}`, style: {
display: "grid",
...(s.direction === "col"
? { gridTemplateRows: `subgrid`, gridRow: "1 / -1" }
: { gridTemplateColumns: `subgrid`, gridColumn: "1 / -1" }),
} }, Array.from({ length: maxCols }, (_, i) => i).map((ci) => {
const c = cells[ci];
let s = {};
if ((c === null || c === void 0 ? void 0 : c.styles) !== undefined) {
if (c?.styles !== undefined) {
for (const style of c.styles) {
s = Object.assign(Object.assign({}, s), styles[style]);
s = { ...s, ...styles[style] };
}
}
return (react_1.default.createElement("div", { className: `cell cell-${ci} cell-${c === null || c === void 0 ? void 0 : c.type}`, key: ci, style: {
return (React.createElement("div", { className: `cell cell-${ci} cell-${c?.type}`, key: ci, style: {
padding: "1px",

@@ -63,3 +57,3 @@ background: s.foreground,

? "center"
: (c === null || c === void 0 ? void 0 : c.type) === "number"
: c?.type === "number"
? "end"

@@ -74,11 +68,11 @@ : "start",

? "center"
: (c === null || c === void 0 ? void 0 : c.type) === "number"
: c?.type === "number"
? "end"
: "center ",
borderTop: `${borderWidth((_b = (_a = s.borderStyle) === null || _a === void 0 ? void 0 : _a.top) !== null && _b !== void 0 ? _b : (((_c = s.borderColor) === null || _c === void 0 ? void 0 : _c.top) ? "medium" : undefined))} ${borderStyle((_d = s.borderStyle) === null || _d === void 0 ? void 0 : _d.top)} ${(_g = (_f = (_e = s.borderColor) === null || _e === void 0 ? void 0 : _e.top) !== null && _f !== void 0 ? _f : s.foreground) !== null && _g !== void 0 ? _g : "rgb(200,200,200)"} `,
borderRight: `${borderWidth((_j = (_h = s.borderStyle) === null || _h === void 0 ? void 0 : _h.right) !== null && _j !== void 0 ? _j : (((_k = s.borderColor) === null || _k === void 0 ? void 0 : _k.right) ? "medium" : undefined))} ${borderStyle((_l = s.borderStyle) === null || _l === void 0 ? void 0 : _l.right)} ${(_p = (_o = (_m = s.borderColor) === null || _m === void 0 ? void 0 : _m.right) !== null && _o !== void 0 ? _o : s.foreground) !== null && _p !== void 0 ? _p : "rgb(200,200,200)"} `,
borderBottom: `${borderWidth((_r = (_q = s.borderStyle) === null || _q === void 0 ? void 0 : _q.bottom) !== null && _r !== void 0 ? _r : (((_s = s.borderColor) === null || _s === void 0 ? void 0 : _s.bottom) ? "medium" : undefined))} ${borderStyle((_t = s.borderStyle) === null || _t === void 0 ? void 0 : _t.bottom)} ${(_w = (_v = (_u = s.borderColor) === null || _u === void 0 ? void 0 : _u.bottom) !== null && _v !== void 0 ? _v : s.foreground) !== null && _w !== void 0 ? _w : "rgb(200,200,200)"} `,
borderLeft: `${borderWidth((_y = (_x = s.borderStyle) === null || _x === void 0 ? void 0 : _x.left) !== null && _y !== void 0 ? _y : (((_z = s.borderColor) === null || _z === void 0 ? void 0 : _z.left) ? "medium" : undefined))} ${borderStyle((_0 = s.borderStyle) === null || _0 === void 0 ? void 0 : _0.left)} ${(_3 = (_2 = (_1 = s.borderColor) === null || _1 === void 0 ? void 0 : _1.left) !== null && _2 !== void 0 ? _2 : s.foreground) !== null && _3 !== void 0 ? _3 : "rgb(200,200,200)"} `,
borderTop: `${borderWidth(s.borderStyle?.top ?? (s.borderColor?.top ? "medium" : undefined))} ${borderStyle(s.borderStyle?.top)} ${s.borderColor?.top ?? s.foreground ?? "rgb(200,200,200)"} `,
borderRight: `${borderWidth(s.borderStyle?.right ?? (s.borderColor?.right ? "medium" : undefined))} ${borderStyle(s.borderStyle?.right)} ${s.borderColor?.right ?? s.foreground ?? "rgb(200,200,200)"} `,
borderBottom: `${borderWidth(s.borderStyle?.bottom ?? (s.borderColor?.bottom ? "medium" : undefined))} ${borderStyle(s.borderStyle?.bottom)} ${s.borderColor?.bottom ?? s.foreground ?? "rgb(200,200,200)"} `,
borderLeft: `${borderWidth(s.borderStyle?.left ?? (s.borderColor?.left ? "medium" : undefined))} ${borderStyle(s.borderStyle?.left)} ${s.borderColor?.left ?? s.foreground ?? "rgb(200,200,200)"} `,
} },
react_1.default.createElement("div", { className: `value value-${ci} value-${c === null || c === void 0 ? void 0 : c.type}`, style: {
React.createElement("div", { className: `value value-${ci} value-${c?.type}`, style: {
fontFamily: "calibri",

@@ -88,8 +82,8 @@ textDecoration: [s.strike ? "line-through" : "", s.underline ? "underline" : ""].join(" "),

fontStyle: s.italic ? "italic" : undefined,
fontSize: `${(_4 = s.size) !== null && _4 !== void 0 ? _4 : 11}px`,
lineHeight: `${(_5 = s.size) !== null && _5 !== void 0 ? _5 : 11}px`,
height: `${(_6 = s.size) !== null && _6 !== void 0 ? _6 : 11}px`,
fontSize: `${s.size ?? 11}px`,
lineHeight: `${s.size ?? 11}px`,
height: `${s.size ?? 11}px`,
color: s.color ? s.color : undefined,
transform: s.textRotation ? `rotate(${s.textRotation})` : undefined,
} }, typeof (c === null || c === void 0 ? void 0 : c.value) === "object" ? c.value.toISOString() : (_7 = c === null || c === void 0 ? void 0 : c.value) !== null && _7 !== void 0 ? _7 : "")));
} }, typeof c?.value === "object" ? c.value.toISOString() : c?.value ?? "")));
}))))));

@@ -96,0 +90,0 @@ })));

@@ -1,3 +0,3 @@

import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";
export declare function toXlsx(...abstractSheets: ReadonlyArray<AbstractSheet>): Buffer;
//# sourceMappingURL=xlsx.d.ts.map

@@ -1,49 +0,12 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.toXlsx = toXlsx;
const XLSX = __importStar(require("xlsx-js-style"));
const _xlsx_sheet_1 = require("./_xlsx-sheet");
const _style_1 = require("./_style");
function toXlsx(...abstractSheets) {
var _a, _b;
import * as XLSX from "xlsx-js-style";
import { xlsxWorkSheet } from "./_xlsx-sheet.js";
import { createStyle } from "./_style.js";
export function toXlsx(...abstractSheets) {
const sheets = {};
const sheetNames = Array();
for (const as of abstractSheets) {
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 styles = Object.fromEntries(as.styles?.map((s) => [s.name, createStyle(s)]) ?? []);
for (const s of as.sheets) {
sheetNames.push(s.name);
sheets[s.name] = (0, _xlsx_sheet_1.xlsxWorkSheet)(s, styles);
sheets[s.name] = xlsxWorkSheet(s, styles);
}

@@ -50,0 +13,0 @@ }

@@ -1,3 +0,3 @@

import { AbstractSheet } from "../abstract-sheet/abstract-sheet";
import { XmlElement } from "./mustache-xml";
import { AbstractSheet } from "../abstract-sheet/abstract-sheet.js";
import { XmlElement } from "./mustache-xml/index.js";
export declare const abstractSheetXml: (template: string, data: any, partials: Record<string, string>, sheetPrefix?: string) => AbstractSheet;

@@ -4,0 +4,0 @@ export declare function abstractSheetOfXml(el: XmlElement, sheetPrefix?: string): unknown;

@@ -1,15 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsedXsd = exports.abstractSheetXml = void 0;
exports.abstractSheetOfXml = abstractSheetOfXml;
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");
const abstractSheetXml = (template, data, partials, sheetPrefix) => abstractSheetOfXml((0, mustache_xml_1.parseMustacheXml)(template, data, partials)[0], sheetPrefix);
exports.abstractSheetXml = abstractSheetXml;
function abstractSheetOfXml(el, sheetPrefix) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
import { borderStyleRecord, } from "../abstract-sheet/abstract-sheet.js";
import { xsd } from "../abstract-sheet/abstract-sheet-xsd.js";
import { parseMustacheXml, parseXsd } from "./mustache-xml/index.js";
export const abstractSheetXml = (template, data, partials, sheetPrefix) => abstractSheetOfXml(parseMustacheXml(template, data, partials)[0], sheetPrefix);
export function abstractSheetOfXml(el, sheetPrefix) {
const children = Array();
const childElements = Array();
for (const child of (_a = el.children) !== null && _a !== void 0 ? _a : []) {
for (const child of el.children ?? []) {
if (child.tagName !== undefined) {

@@ -49,7 +43,7 @@ children.push(abstractSheetOfXml(child, sheetPrefix));

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

@@ -68,14 +62,14 @@ }

case "Cell": {
const styles = (_f = el.attributes.styles) === null || _f === void 0 ? void 0 : _f.split(",");
const styles = el.attributes.styles?.split(",");
if (el.attributes.number !== undefined) {
return Object.assign(Object.assign({}, el.attributes), { type: "number", value: el.attributes.number, styles });
return { ...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 });
return { ...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 });
return { ...el.attributes, type: "date", value: el.attributes.date, styles };
}
else {
return Object.assign(Object.assign({}, el.attributes), { type: "string", value: el.attributes.text, styles });
return { ...el.attributes, type: "string", value: el.attributes.text, styles };
}

@@ -86,9 +80,9 @@ }

case "Style": {
const attributes = Object.assign({}, el.attributes);
const attributes = { ...el.attributes };
if (attributes.borderStyle) {
const border = attributes.borderStyle.toString().split(" ");
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 : ""];
const s0 = borderStyleRecord[border[0] ?? ""];
const s1 = borderStyleRecord[border[1] ?? ""];
const s2 = borderStyleRecord[border[2] ?? ""];
const s3 = borderStyleRecord[border[3] ?? ""];
switch (border.length) {

@@ -135,3 +129,3 @@ default:

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

@@ -1,19 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./abstract-sheet-xml.js"), exports);
__exportStar(require("./mustache-xml/index.js"), exports);
export * from "./abstract-sheet-xml.js";
export * from "./mustache-xml/index.js";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,3 @@

export * from "./validate-mustache-xml";
export * from "./parse-mustache-xml";
export * from "./validate-mustache-xml.js";
export * from "./parse-mustache-xml.js";
//# sourceMappingURL=index.d.ts.map

@@ -1,19 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./validate-mustache-xml"), exports);
__exportStar(require("./parse-mustache-xml"), exports);
export * from "./validate-mustache-xml.js";
export * from "./parse-mustache-xml.js";
//# sourceMappingURL=index.js.map

@@ -1,49 +0,6 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseXsd = exports.parseXml = exports.render = exports.parseMustacheXml = void 0;
exports.parseXmlCustom = parseXmlCustom;
exports.findElement = findElement;
exports.getChildren = getChildren;
const FXmlP = __importStar(require("fast-xml-parser"));
const mustache_1 = __importDefault(require("mustache"));
const parseMustacheXml = (template, data, partials) => (0, exports.parseXml)(mustache_1.default.render(template, data, partials));
exports.parseMustacheXml = parseMustacheXml;
exports.render = mustache_1.default.render;
function parseXmlCustom(text, options) {
import * as FXmlP from "fast-xml-parser";
import Mustache from "mustache";
export const parseMustacheXml = (template, data, partials) => parseXml(Mustache.render(template, data, partials));
export const render = Mustache.render;
export function parseXmlCustom(text, options) {
const parser = new FXmlP.XMLParser(options);

@@ -54,6 +11,4 @@ parser.addEntity("#x2F", "/");

}
const parseXml = (text) => transformFXP(xmlParser.parse(text));
exports.parseXml = parseXml;
const parseXsd = (text) => transformFXP(xsdParser.parse(text.replace(/xs:/g, "")));
exports.parseXsd = parseXsd;
export const parseXml = (text) => transformFXP(xmlParser.parse(text));
export const parseXsd = (text) => transformFXP(xsdParser.parse(text.replace(/xs:/g, "")));
// Transforms fast-xml-parser format to a format that is much easier to work with

@@ -86,3 +41,3 @@ function transformFXP(parsedXml) {

}
function findElement(elements, elementName) {
export function findElement(elements, elementName) {
if (!elementName) {

@@ -109,3 +64,3 @@ return undefined;

}
function getChildren(elements) {
export function getChildren(elements) {
for (const elem of elements) {

@@ -138,3 +93,3 @@ if (elem.tagName === "annotation" || elem.tagName === "attribute") {

attributeValueProcessor: (_name, value) => {
if (!(value === null || value === void 0 ? void 0 : value.trim())) {
if (!value?.trim()) {
return value;

@@ -141,0 +96,0 @@ }

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

import { XmlElement } from "./parse-mustache-xml";
import { XmlElement } from "./parse-mustache-xml.js";
type Range = {

@@ -3,0 +3,0 @@ readonly startLineNumber: number;

@@ -1,40 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateXml = validateXml;
exports.errorToReadableText = errorToReadableText;
const FXmlP = __importStar(require("fast-xml-parser"));
const parse_mustache_xml_1 = require("./parse-mustache-xml");
import * as FXmlP from "fast-xml-parser";
import { parseXml, findElement } from "./parse-mustache-xml.js";
var ErrorType;

@@ -46,3 +9,3 @@ (function (ErrorType) {

// eslint-disable-next-line functional/prefer-readonly-type
function validateXml(fullXml, xsdSchema) {
export function validateXml(fullXml, xsdSchema) {
const errors = [];

@@ -68,3 +31,3 @@ // ignore all mustache brackets

}
const entryPointXml = (0, parse_mustache_xml_1.parseXml)(xml)[0];
const entryPointXml = parseXml(xml)[0];
const entryPointSchema = xsdSchema[0];

@@ -103,4 +66,4 @@ let pos = 0;

const validElements = Object.values(completeSchema.children);
const schemaName = (schemaElement === null || schemaElement === void 0 ? void 0 : schemaElement.attributes.type) || tagName;
const foundSchemaElement = (0, parse_mustache_xml_1.findElement)(validElements, schemaName);
const schemaName = schemaElement?.attributes.type || tagName;
const foundSchemaElement = findElement(validElements, schemaName);
if (!foundSchemaElement) {

@@ -137,3 +100,3 @@ return [createError(`"${tagName}" is not a valid element`, ErrorType.error, range)];

}
const foundChild = (0, parse_mustache_xml_1.findElement)(schemaChildren, childName);
const foundChild = findElement(schemaChildren, childName);
if (!foundChild) {

@@ -192,3 +155,3 @@ const childRange = getRangeOfElement(childName, false);

}
const getErrorMessage = (error) => { var _a; return (_a = error.message.split(/[\t\n]/g)[1]) !== null && _a !== void 0 ? _a : error.message; };
const getErrorMessage = (error) => error.message.split(/[\t\n]/g)[1] ?? error.message;
const createError = (message, type, range) => ({ message, type, range });

@@ -214,3 +177,3 @@ function getPositionFromIndex(lines, index) {

});
function errorToReadableText(errors, templateName = "") {
export function errorToReadableText(errors, templateName = "") {
const errorLines = [];

@@ -217,0 +180,0 @@ if (templateName) {

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.xsd = void 0;
exports.xsd = `<?xml version="1.1" encoding="UTF-8"?>
export const xsd = `<?xml version="1.1" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

@@ -6,0 +3,0 @@

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.borderStyleRecord = void 0;
const borderStyles = [

@@ -18,4 +15,4 @@ "dashDotDot",

];
exports.borderStyleRecord = Object.fromEntries(borderStyles.map((s) => [s, s]));
export const borderStyleRecord = Object.fromEntries(borderStyles.map((s) => [s, s]));
//dummy
//# sourceMappingURL=abstract-sheet.js.map

@@ -1,19 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./abstract-sheet.js"), exports);
__exportStar(require("./abstract-sheet-xsd.xml"), exports);
export * from "./abstract-sheet.js";
export * from "./abstract-sheet-xsd.xml";
//# sourceMappingURL=index.js.map

@@ -1,20 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./abstract-sheet-exporters/index.js"), exports);
__exportStar(require("./abstract-sheet/abstract-sheet.js"), exports);
__exportStar(require("./abstract-sheet-xml/index.js"), exports);
export * from "./abstract-sheet-exporters/index.js";
export * from "./abstract-sheet/abstract-sheet.js";
export * from "./abstract-sheet-xml/index.js";
//# sourceMappingURL=index.js.map
{
"name": "abstract-sheet",
"version": "0.0.8",
"version": "0.0.9",
"description": "Abstract sheet",

@@ -9,3 +9,7 @@ "author": "Divid AB <info@divid.se>",

"main": "lib/index.js",
"type": "module",
"types": "lib/index",
"exports": {
".": "./lib/index.js"
},
"files": [

@@ -32,3 +36,3 @@ "/lib",

},
"gitHead": "df738a548d2391d79ba376947c7707555818e91b"
"gitHead": "4143ed13feb49550a224895bcad0eb7c49da2975"
}

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

import { Style } from "../abstract-sheet/abstract-sheet";
import { Style } from "../abstract-sheet/abstract-sheet.js";

@@ -3,0 +3,0 @@ export function createStyle(style: Style): any {

import * as XLSX from "xlsx-js-style";
import { CellType, Sheet } from "../abstract-sheet/abstract-sheet";
import { CellType, Sheet } from "../abstract-sheet/abstract-sheet.js";

@@ -4,0 +4,0 @@ export function xlsxWorkSheet(sheet: Sheet, styles: Record<string, any>): XLSX.WorkSheet {

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

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

@@ -1,3 +0,3 @@

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

@@ -6,0 +6,0 @@ export function toXlsx(...abstractSheets: ReadonlyArray<AbstractSheet>): Buffer {

@@ -13,5 +13,5 @@ import {

AbstractSheet,
} from "../abstract-sheet/abstract-sheet";
import { xsd } from "../abstract-sheet/abstract-sheet-xsd";
import { parseMustacheXml, parseXsd, XmlElement } from "./mustache-xml";
} from "../abstract-sheet/abstract-sheet.js";
import { xsd } from "../abstract-sheet/abstract-sheet-xsd.js";
import { parseMustacheXml, parseXsd, XmlElement } from "./mustache-xml/index.js";

@@ -18,0 +18,0 @@ export const abstractSheetXml = (

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

export * from "./validate-mustache-xml";
export * from "./parse-mustache-xml";
export * from "./validate-mustache-xml.js";
export * from "./parse-mustache-xml.js";
import * as FXmlP from "fast-xml-parser";
import { XmlElement, parseXml, findElement } from "./parse-mustache-xml";
import { XmlElement, parseXml, findElement } from "./parse-mustache-xml.js";

@@ -4,0 +4,0 @@ enum ErrorType {

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

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