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

@steelbreeze/landscape

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@steelbreeze/landscape - npm Package Compare versions

Comparing version 3.5.3 to 3.6.0

docs/api/v3/interfaces/element.html

2

docs/api/v3/assets/js/search.js

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

window.searchData = {"kinds":{"64":"Function","256":"Interface","1024":"Property"},"rows":[{"id":0,"kind":64,"name":"table","url":"index.html#table","classes":"tsd-kind-function tsd-has-type-parameter"},{"id":1,"kind":64,"name":"split","url":"index.html#split","classes":"tsd-kind-function tsd-has-type-parameter"},{"id":2,"kind":64,"name":"merge","url":"index.html#merge","classes":"tsd-kind-function tsd-has-type-parameter"},{"id":3,"kind":256,"name":"Key","url":"interfaces/key.html","classes":"tsd-kind-interface"},{"id":4,"kind":1024,"name":"text","url":"interfaces/key.html#text","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Key"},{"id":5,"kind":1024,"name":"style","url":"interfaces/key.html#style","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Key"},{"id":6,"kind":256,"name":"Cell","url":"interfaces/cell.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":7,"kind":1024,"name":"index","url":"interfaces/cell.html#index","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Cell"},{"id":8,"kind":1024,"name":"source","url":"interfaces/cell.html#source","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Cell"},{"id":9,"kind":1024,"name":"rows","url":"interfaces/cell.html#rows","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Cell"},{"id":10,"kind":1024,"name":"cols","url":"interfaces/cell.html#cols","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Cell"},{"id":11,"kind":1024,"name":"text","url":"interfaces/cell.html#text","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"Cell"},{"id":12,"kind":1024,"name":"style","url":"interfaces/cell.html#style","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"Cell"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,22.336]],["parent/0",[]],["name/1",[1,22.336]],["parent/1",[]],["name/2",[2,22.336]],["parent/2",[]],["name/3",[3,13.863]],["parent/3",[]],["name/4",[4,17.228]],["parent/4",[3,1.104]],["name/5",[5,17.228]],["parent/5",[3,1.104]],["name/6",[6,6.242]],["parent/6",[]],["name/7",[7,22.336]],["parent/7",[6,0.497]],["name/8",[8,22.336]],["parent/8",[6,0.497]],["name/9",[9,22.336]],["parent/9",[6,0.497]],["name/10",[10,22.336]],["parent/10",[6,0.497]],["name/11",[4,17.228]],["parent/11",[6,0.497]],["name/12",[5,17.228]],["parent/12",[6,0.497]]],"invertedIndex":[["cell",{"_index":6,"name":{"6":{}},"parent":{"7":{},"8":{},"9":{},"10":{},"11":{},"12":{}}}],["cols",{"_index":10,"name":{"10":{}},"parent":{}}],["index",{"_index":7,"name":{"7":{}},"parent":{}}],["key",{"_index":3,"name":{"3":{}},"parent":{"4":{},"5":{}}}],["merge",{"_index":2,"name":{"2":{}},"parent":{}}],["rows",{"_index":9,"name":{"9":{}},"parent":{}}],["source",{"_index":8,"name":{"8":{}},"parent":{}}],["split",{"_index":1,"name":{"1":{}},"parent":{}}],["style",{"_index":5,"name":{"5":{},"12":{}},"parent":{}}],["table",{"_index":0,"name":{"0":{}},"parent":{}}],["text",{"_index":4,"name":{"4":{},"11":{}},"parent":{}}]],"pipeline":[]}}
window.searchData = {"kinds":{"64":"Function","256":"Interface","1024":"Property"},"rows":[{"id":0,"kind":64,"name":"table","url":"index.html#table","classes":"tsd-kind-function tsd-has-type-parameter"},{"id":1,"kind":64,"name":"merge","url":"index.html#merge","classes":"tsd-kind-function"},{"id":2,"kind":256,"name":"Element","url":"interfaces/element.html","classes":"tsd-kind-interface"},{"id":3,"kind":1024,"name":"style","url":"interfaces/element.html#style","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Element"},{"id":4,"kind":1024,"name":"text","url":"interfaces/element.html#text","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Element"},{"id":5,"kind":256,"name":"Cell","url":"interfaces/cell.html","classes":"tsd-kind-interface"},{"id":6,"kind":1024,"name":"rows","url":"interfaces/cell.html#rows","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Cell"},{"id":7,"kind":1024,"name":"cols","url":"interfaces/cell.html#cols","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Cell"},{"id":8,"kind":1024,"name":"style","url":"interfaces/cell.html#style","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"Cell"},{"id":9,"kind":1024,"name":"text","url":"interfaces/cell.html#text","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-inherited","parent":"Cell"}],"index":{"version":"2.3.9","fields":["name","parent"],"fieldVectors":[["name/0",[0,19.924]],["parent/0",[]],["name/1",[1,19.924]],["parent/1",[]],["name/2",[2,11.451]],["parent/2",[]],["name/3",[3,14.816]],["parent/3",[2,0.9]],["name/4",[4,14.816]],["parent/4",[2,0.9]],["name/5",[5,6.931]],["parent/5",[]],["name/6",[6,19.924]],["parent/6",[5,0.545]],["name/7",[7,19.924]],["parent/7",[5,0.545]],["name/8",[3,14.816]],["parent/8",[5,0.545]],["name/9",[4,14.816]],["parent/9",[5,0.545]]],"invertedIndex":[["cell",{"_index":5,"name":{"5":{}},"parent":{"6":{},"7":{},"8":{},"9":{}}}],["cols",{"_index":7,"name":{"7":{}},"parent":{}}],["element",{"_index":2,"name":{"2":{}},"parent":{"3":{},"4":{}}}],["merge",{"_index":1,"name":{"1":{}},"parent":{}}],["rows",{"_index":6,"name":{"6":{}},"parent":{}}],["style",{"_index":3,"name":{"3":{},"8":{}},"parent":{}}],["table",{"_index":0,"name":{"0":{}},"parent":{}}],["text",{"_index":4,"name":{"4":{},"9":{}},"parent":{}}]],"pipeline":[]}}

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

var landscape;(()=>{"use strict";var e={};(()=>{var t=e;function n(e,t,n,s){const c=t.x.map(((t,o)=>n?r(e,(e=>e[o].length),s):1)),l=e.map((e=>n?1:r(e,(e=>e.length),s)));return o(e,l,((e,n,s,r)=>o(e,c,((e,t,o)=>({...e[Math.floor(e.length*(s+o)/(t*n))]})),t.y[r].map((e=>i(a(`axis y ${e.key}`,e.value)))))),t.x[0].map(((e,n)=>o(t.x,c,(e=>i(a(`axis x ${e[n].key}`,e[n].value))),t.y[0].map((()=>i(a("axis xy"))))))))}function s(e,t){t.index.forEach(((n,s)=>{e.index.includes(n)||(e.index.push(n),e.source.push(t.source[s]))}))}function o(e,t,n,s){return e.forEach(((e,o)=>{const c=t[o];for(let t=0;t<c;++t)s.push(n(e,c,t,o))})),s}Object.defineProperty(t,"__esModule",{value:!0}),t.merge=t.split=t.table=void 0,t.table=function(e,t,s,o,c=!1){const r={index:0};return n(e.map((e=>e.map((e=>e.length?function(e,t,n){const s=[];for(const o of e){const e=t(o);let c=s.find((t=>u(t,e)));c||s.push(c=i(e)),c.index.push(n.index++),c.source.push(o)}return s}(e,s,r):[i(a("empty"))])))),t,o,c)},t.split=n,t.merge=function(e,t,n){let o;c(e,((r,l)=>{c(r,((c,a)=>{n&&l&&(o=e[l-1][a])&&u(o,c)&&o.cols===c.cols?(o.rows+=c.rows,s(o,c),r.splice(a,1)):t&&a&&(o=r[a-1])&&u(o,c)&&o.rows===c.rows&&(o.cols+=c.cols,s(o,c),r.splice(a,1))}))}))};const c=(e,t)=>{for(let n=e.length;n--;)t(e[n],n)};function r(e,t,n){const s=e.map((e=>t(e)||1));return n?s.reduce(((e,t)=>e*t/l(e,t))):Math.max(...s)}const l=(e,t)=>t?l(t,e%t):e,u=(e,t)=>e.text===t.text&&e.style===t.style,a=(e,t="")=>({text:t,style:e}),i=e=>({...e,index:[],source:[],rows:1,cols:1})})(),landscape=e})();
var landscape;(()=>{"use strict";var e={};(()=>{var t=e;function s(e,t,s,o){const a=t.x.map(((t,n)=>s?l(e,(e=>e[n].length),o):1)),r=e.map((e=>s?1:l(e,(e=>e.length),o)));return n(e,r,((e,s,o,l)=>n(e,a,((e,t,n)=>({...e[Math.floor(e.length*(o+n)/(t*s))]})),t.y[l].map((e=>u(c(`axis y ${e.key}`,e.value)))))),t.x[0].map(((e,s)=>n(t.x,a,(e=>u(c(`axis x ${e[s].key}`,e[s].value))),t.y[0].map((()=>u(c("axis xy"))))))))}function n(e,t,s,n){return e.forEach(((e,o)=>{const l=t[o];for(let t=0;t<l;++t)n.push(s(e,l,t,o))})),n}Object.defineProperty(t,"__esModule",{value:!0}),t.merge=t.split=t.table=void 0,t.table=function(e,t,n,o,l=!1){return s(e.map((e=>e.map((e=>e.length?function(e,t){const s=[];for(const n of e){const e=t(n);let o=s.find((t=>r(t,e)));o||s.push(o=u(e))}return s}(e,n):[u(c("empty"))])))),t,o,l)},t.split=s,t.merge=function(e,t,s){let n;o(e,((l,a)=>{o(l,((o,c)=>{s&&a&&(n=e[a-1][c])&&r(n,o)&&n.cols===o.cols?(n.rows+=o.rows,l.splice(c,1)):t&&c&&(n=l[c-1])&&r(n,o)&&n.rows===o.rows&&(n.cols+=o.cols,l.splice(c,1))}))}))};const o=(e,t)=>{for(let s=e.length;s--;)t(e[s],s)};function l(e,t,s){const n=e.map((e=>t(e)||1));return s?n.reduce(((e,t)=>e*t/a(e,t))):Math.max(...n)}const a=(e,t)=>t?a(t,e%t):e,r=(e,t)=>e.key===t.key&&e.value===t.value&&e.style===t.style,c=(e,t="",s="")=>({key:s,value:t,style:e}),u=e=>({...e,rows:1,cols:1})})(),landscape=e})();

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

var render;(()=>{"use strict";var e={};(()=>{var t=e;function n(e){const t=document.createElement("tr");for(const n of e)t.appendChild(c(n));return t}function c(e){const t=document.createElement(e.style.includes("axis")?"th":"td");t.colSpan=e.cols,t.rowSpan=e.rows,t.className=`cell ${e.style}`;const n=document.createElement("div");return n.appendChild(document.createTextNode(e.altText||e.text)),t.appendChild(n),t}Object.defineProperty(t,"__esModule",{value:!0}),t.table=void 0,t.table=function(e,t,c){const o=document.createElement("table");o.id=t,o.classList.add(c);for(const t of e)o.appendChild(n(t));return o}})(),render=e})();
var render;(()=>{"use strict";var e={};(()=>{var t=e;function n(e){const t=document.createElement("tr");for(const n of e)t.appendChild(c(n));return t}function c(e){const t=document.createElement(e.style.includes("axis")?"th":"td");t.colSpan=e.cols,t.rowSpan=e.rows,t.className=`cell ${e.style}`;const n=document.createElement("div");return n.appendChild(document.createTextNode(e.text||e.value||"")),t.appendChild(n),t}Object.defineProperty(t,"__esModule",{value:!0}),t.table=void 0,t.table=function(e,t,c){const o=document.createElement("table");o.id=t,o.classList.add(c);for(const t of e)o.appendChild(n(t));return o}})(),render=e})();

@@ -1,15 +0,11 @@

import { Axes, Cube, Function, Row } from '@steelbreeze/pivot';
import { Axes, Cube, Function, Pair, Row } from '@steelbreeze/pivot';
/** The final text and class name to use when rendering cells in a table. */
export interface Key {
/** The text to use in the final table rendering. */
text: string;
export interface Element extends Pair {
/** The class name to use in the final table rendering. */
style: string;
/** Optional text to display in place of Pair.value (which is used to de-dup) */
text?: string;
}
/** An extension of key, adding the number of rows and columns the key will occupy in the final table rendering. */
export interface Cell<TRow extends Row> extends Key {
/** Unique keys for the source context. */
index: Array<number>;
/** The the rows that this this key came from. */
source: Array<TRow>;
/** An extension of Element, adding the number of rows and columns the element will occupy in the final table rendering. */
export interface Cell extends Element {
/** The number of rows to occupy. */

@@ -24,14 +20,12 @@ rows: number;

* @param axes The x and y axes used in the pivot operation to create the cube.
* @param getKey A callback to generate a key containing the text and className used in the table from the source records,
* @param getElement A callback to generate an element containing the details used in table rendering,
* @param onX A flag to indicate if cells in cube containing multiple values should be split on the x axis (if not, the y axis will be used).
* @param precise A flag to control the method that cells are split; set to true to yeild an even number of splits for rows/columns.
*/
export declare function table<TRow extends Row>(cube: Cube<TRow>, axes: Axes<TRow>, getKey: Function<TRow, Key>, onX: boolean, precise?: boolean): Array<Array<Cell<TRow>>>;
export declare function table<TRow extends Row>(cube: Cube<TRow>, axes: Axes<TRow>, getElement: Function<TRow, Element>, onX: boolean, precise?: boolean): Array<Array<Cell>>;
/**
* Splits a cube of keys into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @param cube The source cube.
* @param axes The x and y axes used in the pivot operation to create the cube.
* @param onX A flag to indicate if cells in cube containing multiple values should be split on the x axis (if not, the y axis will be used).
* Splits a cube of cells into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @hidden
*/
export declare function split<TRow extends Row>(cells: Cube<Cell<TRow>>, axes: Axes<TRow>, onX: boolean, precise: boolean): Array<Array<Cell<TRow>>>;
export declare function split<TRow extends Row>(cells: Cube<Cell>, axes: Axes<TRow>, onX: boolean, precise: boolean): Array<Array<Cell>>;
/**

@@ -43,2 +37,2 @@ * Merge adjacent cells in a split table on the y and/or x axes.

*/
export declare function merge<TRow extends Row>(cells: Array<Array<Cell<TRow>>>, onX: boolean, onY: boolean): void;
export declare function merge(cells: Array<Array<Cell>>, onX: boolean, onY: boolean): void;

@@ -8,17 +8,14 @@ "use strict";

* @param axes The x and y axes used in the pivot operation to create the cube.
* @param getKey A callback to generate a key containing the text and className used in the table from the source records,
* @param getElement A callback to generate an element containing the details used in table rendering,
* @param onX A flag to indicate if cells in cube containing multiple values should be split on the x axis (if not, the y axis will be used).
* @param precise A flag to control the method that cells are split; set to true to yeild an even number of splits for rows/columns.
*/
function table(cube, axes, getKey, onX, precise = false) {
const identity = { index: 0 };
// convert the source data to keys and remove resulting duplicates; create the resultant table
return split(cube.map(row => row.map(table => table.length ? cells(table, getKey, identity) : [cell(makeKey('empty'))])), axes, onX, precise);
function table(cube, axes, getElement, onX, precise = false) {
// convert the source data to cells and remove resulting duplicates; create the resultant table
return split(cube.map(row => row.map(table => table.length ? cells(table, getElement) : [cell(element('empty'))])), axes, onX, precise);
}
exports.table = table;
/**
* Splits a cube of keys into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @param cube The source cube.
* @param axes The x and y axes used in the pivot operation to create the cube.
* @param onX A flag to indicate if cells in cube containing multiple values should be split on the x axis (if not, the y axis will be used).
* Splits a cube of cells into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @hidden
*/

@@ -29,21 +26,18 @@ function split(cells, axes, onX, precise) {

const ySplits = cells.map(row => onX ? 1 : leastCommonMultiple(row, table => table.length, precise));
// console.log(`xSplits: ${xSplits}`);
// console.log(`ySplits: ${ySplits}`);
// iterate and expand the y axis based on the split data
return reduce(cells, ySplits, (row, ySplit, ysi, iY) => {
// iterate and expand the x axis based on the split data
return reduce(row, xSplits, (cell, xSplit, xsi) => {
// generate the cube cells
return { ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] };
// generate the y axis row header cells
}, axes.y[iY].map(criterion => cell(makeKey(`axis y ${criterion.key}`, criterion.value))));
// generate the x axis column header rows
}, axes.x[0].map((_, iC) => {
// iterate and expand the x axis
return reduce(axes.x, xSplits, x => {
// generate the x axis cells
return cell(makeKey(`axis x ${x[iC].key}`, x[iC].value));
// generate the x/y header
}, axes.y[0].map(() => cell(makeKey('axis xy'))));
}));
return reduce(cells, ySplits, (row, ySplit, ysi, iY) =>
// iterate and expand the x axis based on the split data
reduce(row, xSplits, (cell, xSplit, xsi) =>
// generate the cube cells
({ ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] }),
// generate the y axis row header cells
axes.y[iY].map(criterion => cell(element(`axis y ${criterion.key}`, criterion.value)))),
// generate the x axis column header rows
axes.x[0].map((_, iC) =>
// iterate and expand the x axis
reduce(axes.x, xSplits, x =>
// generate the x axis cells
cell(element(`axis x ${x[iC].key}`, x[iC].value)),
// generate the x/y header
axes.y[0].map(() => cell(element('axis xy'))))));
}

@@ -61,10 +55,8 @@ exports.split = split;

forEachRev(row, (cell, iX) => {
if (onY && iY && (next = cells[iY - 1][iX]) && keyEquals(next, cell) && next.cols === cell.cols) {
if (onY && iY && (next = cells[iY - 1][iX]) && equals(next, cell) && next.cols === cell.cols) {
next.rows += cell.rows;
mergeContext(next, cell);
row.splice(iX, 1);
}
else if (onX && iX && (next = row[iX - 1]) && keyEquals(next, cell) && next.rows === cell.rows) {
else if (onX && iX && (next = row[iX - 1]) && equals(next, cell) && next.rows === cell.rows) {
next.cols += cell.cols;
mergeContext(next, cell);
row.splice(iX, 1);

@@ -77,27 +69,13 @@ }

/**
* Merges the context of two adjacent cells.
* @hidden
*/
function mergeContext(next, cell) {
cell.index.forEach((index, i) => {
if (!next.index.includes(index)) {
next.index.push(index);
next.source.push(cell.source[i]);
}
});
}
/**
* Convert a table of rows into a table of cells.
* @hidden
*/
function cells(table, getKey, identity) {
function cells(table, getElement) {
const result = [];
for (const row of table) {
const key = getKey(row);
let existing = result.find(cell => keyEquals(cell, key));
const element = getElement(row);
let existing = result.find(cell => equals(cell, element));
if (!existing) {
result.push(existing = cell(key));
result.push(existing = cell(element));
}
existing.index.push(identity.index++);
existing.source.push(row);
}

@@ -142,11 +120,11 @@ return result;

/**
* Compare two keys for equality
* Compare two Elements for equality
* @hidden
*/
const keyEquals = (a, b) => a.text === b.text && a.style === b.style;
const equals = (a, b) => a.key === b.key && a.value === b.value && a.style === b.style;
/**
* Creates a key within a table.
* Creates a Element.
* @hidden
*/
const makeKey = (style, text = '') => ({ text, style });
const element = (style, value = '', key = '') => ({ key, value, style });
/**

@@ -156,2 +134,2 @@ * Creates a cell within a table.

*/
const cell = (key) => ({ ...key, index: [], source: [], rows: 1, cols: 1 });
const cell = (key) => ({ ...key, rows: 1, cols: 1 });

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

import { Row } from '@steelbreeze/pivot';
import { Cell } from '.';

@@ -8,2 +7,2 @@ /**

*/
export declare function table<TRow extends Row>(tableData: Array<Array<Cell<TRow>>>, elementId: string, className: string): HTMLTableElement;
export declare function table(tableData: Array<Array<Cell>>, elementId: string, className: string): HTMLTableElement;

@@ -34,5 +34,5 @@ "use strict";

const divElement = document.createElement('div');
divElement.appendChild(document.createTextNode(cellData.altText || cellData.text));
divElement.appendChild(document.createTextNode(cellData.text || cellData.value || ''));
cellElement.appendChild(divElement);
return cellElement;
}

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

var landscape;(()=>{"use strict";var e={};(()=>{var t=e;function n(e,t,n,s){const c=t.x.map(((t,o)=>n?r(e,(e=>e[o].length),s):1)),l=e.map((e=>n?1:r(e,(e=>e.length),s)));return o(e,l,((e,n,s,r)=>o(e,c,((e,t,o)=>({...e[Math.floor(e.length*(s+o)/(t*n))]})),t.y[r].map((e=>i(a(`axis y ${e.key}`,e.value)))))),t.x[0].map(((e,n)=>o(t.x,c,(e=>i(a(`axis x ${e[n].key}`,e[n].value))),t.y[0].map((()=>i(a("axis xy"))))))))}function s(e,t){t.index.forEach(((n,s)=>{e.index.includes(n)||(e.index.push(n),e.source.push(t.source[s]))}))}function o(e,t,n,s){return e.forEach(((e,o)=>{const c=t[o];for(let t=0;t<c;++t)s.push(n(e,c,t,o))})),s}Object.defineProperty(t,"__esModule",{value:!0}),t.merge=t.split=t.table=void 0,t.table=function(e,t,s,o,c=!1){const r={index:0};return n(e.map((e=>e.map((e=>e.length?function(e,t,n){const s=[];for(const o of e){const e=t(o);let c=s.find((t=>u(t,e)));c||s.push(c=i(e)),c.index.push(n.index++),c.source.push(o)}return s}(e,s,r):[i(a("empty"))])))),t,o,c)},t.split=n,t.merge=function(e,t,n){let o;c(e,((r,l)=>{c(r,((c,a)=>{n&&l&&(o=e[l-1][a])&&u(o,c)&&o.cols===c.cols?(o.rows+=c.rows,s(o,c),r.splice(a,1)):t&&a&&(o=r[a-1])&&u(o,c)&&o.rows===c.rows&&(o.cols+=c.cols,s(o,c),r.splice(a,1))}))}))};const c=(e,t)=>{for(let n=e.length;n--;)t(e[n],n)};function r(e,t,n){const s=e.map((e=>t(e)||1));return n?s.reduce(((e,t)=>e*t/l(e,t))):Math.max(...s)}const l=(e,t)=>t?l(t,e%t):e,u=(e,t)=>e.text===t.text&&e.style===t.style,a=(e,t="")=>({text:t,style:e}),i=e=>({...e,index:[],source:[],rows:1,cols:1})})(),landscape=e})();
var landscape;(()=>{"use strict";var e={};(()=>{var t=e;function s(e,t,s,o){const a=t.x.map(((t,n)=>s?l(e,(e=>e[n].length),o):1)),r=e.map((e=>s?1:l(e,(e=>e.length),o)));return n(e,r,((e,s,o,l)=>n(e,a,((e,t,n)=>({...e[Math.floor(e.length*(o+n)/(t*s))]})),t.y[l].map((e=>u(c(`axis y ${e.key}`,e.value)))))),t.x[0].map(((e,s)=>n(t.x,a,(e=>u(c(`axis x ${e[s].key}`,e[s].value))),t.y[0].map((()=>u(c("axis xy"))))))))}function n(e,t,s,n){return e.forEach(((e,o)=>{const l=t[o];for(let t=0;t<l;++t)n.push(s(e,l,t,o))})),n}Object.defineProperty(t,"__esModule",{value:!0}),t.merge=t.split=t.table=void 0,t.table=function(e,t,n,o,l=!1){return s(e.map((e=>e.map((e=>e.length?function(e,t){const s=[];for(const n of e){const e=t(n);let o=s.find((t=>r(t,e)));o||s.push(o=u(e))}return s}(e,n):[u(c("empty"))])))),t,o,l)},t.split=s,t.merge=function(e,t,s){let n;o(e,((l,a)=>{o(l,((o,c)=>{s&&a&&(n=e[a-1][c])&&r(n,o)&&n.cols===o.cols?(n.rows+=o.rows,l.splice(c,1)):t&&c&&(n=l[c-1])&&r(n,o)&&n.rows===o.rows&&(n.cols+=o.cols,l.splice(c,1))}))}))};const o=(e,t)=>{for(let s=e.length;s--;)t(e[s],s)};function l(e,t,s){const n=e.map((e=>t(e)||1));return s?n.reduce(((e,t)=>e*t/a(e,t))):Math.max(...n)}const a=(e,t)=>t?a(t,e%t):e,r=(e,t)=>e.key===t.key&&e.value===t.value&&e.style===t.style,c=(e,t="",s="")=>({key:s,value:t,style:e}),u=e=>({...e,rows:1,cols:1})})(),landscape=e})();

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

var render;(()=>{"use strict";var e={};(()=>{var t=e;function n(e){const t=document.createElement("tr");for(const n of e)t.appendChild(c(n));return t}function c(e){const t=document.createElement(e.style.includes("axis")?"th":"td");t.colSpan=e.cols,t.rowSpan=e.rows,t.className=`cell ${e.style}`;const n=document.createElement("div");return n.appendChild(document.createTextNode(e.altText||e.text)),t.appendChild(n),t}Object.defineProperty(t,"__esModule",{value:!0}),t.table=void 0,t.table=function(e,t,c){const o=document.createElement("table");o.id=t,o.classList.add(c);for(const t of e)o.appendChild(n(t));return o}})(),render=e})();
var render;(()=>{"use strict";var e={};(()=>{var t=e;function n(e){const t=document.createElement("tr");for(const n of e)t.appendChild(c(n));return t}function c(e){const t=document.createElement(e.style.includes("axis")?"th":"td");t.colSpan=e.cols,t.rowSpan=e.rows,t.className=`cell ${e.style}`;const n=document.createElement("div");return n.appendChild(document.createTextNode(e.text||e.value||"")),t.appendChild(n),t}Object.defineProperty(t,"__esModule",{value:!0}),t.table=void 0,t.table=function(e,t,c){const o=document.createElement("table");o.id=t,o.classList.add(c);for(const t of e)o.appendChild(n(t));return o}})(),render=e})();
{
"name": "@steelbreeze/landscape",
"version": "3.5.3",
"version": "3.6.0",
"description": "Landscape map viewpoint visualisation",

@@ -5,0 +5,0 @@ "main": "lib/node/index.js",

@@ -1,20 +0,14 @@

import { Axes, Cube, Function, Row, Table } from '@steelbreeze/pivot';
import { Axes, Cube, Function, Pair, Row, Table } from '@steelbreeze/pivot';
/** The final text and class name to use when rendering cells in a table. */
export interface Key {
/** The text to use in the final table rendering. */
text: string;
export interface Element extends Pair {
/** The class name to use in the final table rendering. */
style: string;
/** Optional text to display in place of Pair.value (which is used to de-dup) */
text?: string;
}
/** An extension of key, adding the number of rows and columns the key will occupy in the final table rendering. */
export interface Cell<TRow extends Row> extends Key {
/** Unique keys for the source context. */
index: Array<number>;
/** The the rows that this this key came from. */
source: Array<TRow>;
/** An extension of Element, adding the number of rows and columns the element will occupy in the final table rendering. */
export interface Cell extends Element {
/** The number of rows to occupy. */

@@ -31,20 +25,16 @@ rows: number;

* @param axes The x and y axes used in the pivot operation to create the cube.
* @param getKey A callback to generate a key containing the text and className used in the table from the source records,
* @param getElement A callback to generate an element containing the details used in table rendering,
* @param onX A flag to indicate if cells in cube containing multiple values should be split on the x axis (if not, the y axis will be used).
* @param precise A flag to control the method that cells are split; set to true to yeild an even number of splits for rows/columns.
*/
export function table<TRow extends Row>(cube: Cube<TRow>, axes: Axes<TRow>, getKey: Function<TRow, Key>, onX: boolean, precise: boolean = false): Array<Array<Cell<TRow>>> {
const identity = { index: 0 };
// convert the source data to keys and remove resulting duplicates; create the resultant table
return split(cube.map(row => row.map(table => table.length ? cells(table, getKey, identity) : <Cell<TRow>[]>[cell(makeKey('empty'))])), axes, onX, precise);
export function table<TRow extends Row>(cube: Cube<TRow>, axes: Axes<TRow>, getElement: Function<TRow, Element>, onX: boolean, precise: boolean = false): Array<Array<Cell>> {
// convert the source data to cells and remove resulting duplicates; create the resultant table
return split(cube.map(row => row.map(table => table.length ? cells(table, getElement) : <Cell[]>[cell(element('empty'))])), axes, onX, precise);
}
/**
* Splits a cube of keys into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @param cube The source cube.
* @param axes The x and y axes used in the pivot operation to create the cube.
* @param onX A flag to indicate if cells in cube containing multiple values should be split on the x axis (if not, the y axis will be used).
* Splits a cube of cells into a table, creating mutiple rows or columns where a cell in a cube has multiple values.
* @hidden
*/
export function split<TRow extends Row>(cells: Cube<Cell<TRow>>, axes: Axes<TRow>, onX: boolean, precise: boolean): Array<Array<Cell<TRow>>> {
export function split<TRow extends Row>(cells: Cube<Cell>, axes: Axes<TRow>, onX: boolean, precise: boolean): Array<Array<Cell>> {
// calcuate the x and y splits required

@@ -54,29 +44,26 @@ const xSplits = axes.x.map((_, iX) => onX ? leastCommonMultiple(cells, row => row[iX].length, precise) : 1);

// console.log(`xSplits: ${xSplits}`);
// console.log(`ySplits: ${ySplits}`);
// iterate and expand the y axis based on the split data
return reduce(cells, ySplits, (row, ySplit, ysi, iY) => {
return reduce(cells, ySplits, (row, ySplit, ysi, iY) =>
// iterate and expand the x axis based on the split data
return reduce(row, xSplits, (cell, xSplit, xsi) => {
reduce(row, xSplits, (cell, xSplit, xsi) =>
// generate the cube cells
return { ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] };
({ ...cell[Math.floor(cell.length * (ysi + xsi) / (xSplit * ySplit))] }),
// generate the y axis row header cells
}, axes.y[iY].map(criterion => cell(makeKey(`axis y ${criterion.key}`, criterion.value))));
axes.y[iY].map(criterion => cell(element(`axis y ${criterion.key}`, criterion.value)))),
// generate the x axis column header rows
}, axes.x[0].map((_, iC) => {
axes.x[0].map((_, iC) =>
// iterate and expand the x axis
return reduce(axes.x, xSplits, x => {
// iterate and expand the x axis
reduce(axes.x, xSplits, x =>
// generate the x axis cells
return cell(makeKey(`axis x ${x[iC].key}`, x[iC].value));
// generate the x axis cells
cell(element(`axis x ${x[iC].key}`, x[iC].value)),
// generate the x/y header
}, axes.y[0].map(() => cell(makeKey('axis xy'))));
}));
// generate the x/y header
axes.y[0].map(() => cell(element('axis xy'))))
));
}

@@ -90,3 +77,3 @@

*/
export function merge<TRow extends Row>(cells: Array<Array<Cell<TRow>>>, onX: boolean, onY: boolean): void {
export function merge(cells: Array<Array<Cell>>, onX: boolean, onY: boolean): void {
let next;

@@ -96,9 +83,7 @@

forEachRev(row, (cell, iX) => {
if (onY && iY && (next = cells[iY - 1][iX]) && keyEquals(next, cell) && next.cols === cell.cols) {
if (onY && iY && (next = cells[iY - 1][iX]) && equals(next, cell) && next.cols === cell.cols) {
next.rows += cell.rows;
mergeContext(next, cell);
row.splice(iX, 1);
} else if (onX && iX && (next = row[iX - 1]) && keyEquals(next, cell) && next.rows === cell.rows) {
} else if (onX && iX && (next = row[iX - 1]) && equals(next, cell) && next.rows === cell.rows) {
next.cols += cell.cols;
mergeContext(next, cell);
row.splice(iX, 1);

@@ -111,31 +96,15 @@ }

/**
* Merges the context of two adjacent cells.
* @hidden
*/
function mergeContext<TRow extends Row>(next: Cell<TRow>, cell: Cell<TRow>): void {
cell.index.forEach((index, i) => {
if (!next.index.includes(index)) {
next.index.push(index);
next.source.push(cell.source[i]);
}
});
}
/**
* Convert a table of rows into a table of cells.
* @hidden
*/
function cells<TRow extends Row>(table: Table<TRow>, getKey: Function<TRow, Key>, identity: { index: number }): Table<Cell<TRow>> {
const result: Table<Cell<TRow>> = [];
function cells<TRow extends Row>(table: Table<TRow>, getElement: Function<TRow, Element>): Table<Cell> {
const result: Table<Cell> = [];
for (const row of table) {
const key = getKey(row);
let existing = result.find(cell => keyEquals(cell, key));
const element = getElement(row);
let existing = result.find(cell => equals(cell, element));
if (!existing) {
result.push(existing = cell(key));
result.push(existing = cell(element));
}
existing.index.push(identity.index++);
existing.source.push(row);
}

@@ -179,3 +148,3 @@

return precise ? counts.reduce((a, b) => (a * b) / greatestCommonFactor(a, b)) : Math.max(...counts);
return precise ? counts.reduce((a, b) => (a * b) / greatestCommonFactor(a, b)) : Math.max(...counts); // TODO: restore this method to be just LCM
}

@@ -187,18 +156,15 @@

*/
const greatestCommonFactor = (a: number, b: number): number =>
b ? greatestCommonFactor(b, a % b) : a;
const greatestCommonFactor = (a: number, b: number): number => b ? greatestCommonFactor(b, a % b) : a;
/**
* Compare two keys for equality
* Compare two Elements for equality
* @hidden
*/
const keyEquals = (a: Key, b: Key): boolean =>
a.text === b.text && a.style === b.style;
const equals = (a: Element, b: Element): boolean => a.key === b.key && a.value === b.value && a.style === b.style;
/**
* Creates a key within a table.
* Creates a Element.
* @hidden
*/
const makeKey = (style: string, text: string = ''): Key =>
({ text, style });
const element = (style: string, value: string = '', key = ''): Element => ({ key, value, style });

@@ -209,3 +175,2 @@ /**

*/
const cell = <TRow extends Row>(key: Key): Cell<TRow> =>
({ ...key, index: [], source: [], rows: 1, cols: 1 });
const cell = (key: Element): Cell => ({ ...key, rows: 1, cols: 1 });

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

import { Row } from '@steelbreeze/pivot';
import { Cell } from '.';

@@ -9,3 +8,3 @@

*/
export function table<TRow extends Row>(tableData: Array<Array<Cell<TRow>>>, elementId: string, className: string): HTMLTableElement {
export function table(tableData: Array<Array<Cell>>, elementId: string, className: string): HTMLTableElement {
const tableElement = document.createElement('table');

@@ -23,3 +22,3 @@ tableElement.id = elementId;

// render a row in a table
function row<TRow extends Row>(rowData: Array<Cell<TRow>>): HTMLTableRowElement {
function row(rowData: Array<Cell>): HTMLTableRowElement {
const rowElement = document.createElement('tr');

@@ -35,3 +34,3 @@

// render a cell in a table with a child div
function cell(cellData: any): HTMLTableCellElement {
function cell(cellData: Cell): HTMLTableCellElement {
const cellElement = document.createElement(cellData.style.includes('axis') ? 'th' : 'td');

@@ -43,3 +42,3 @@ cellElement.colSpan = cellData.cols;

const divElement = document.createElement('div');
divElement.appendChild(document.createTextNode(cellData.altText || cellData.text));
divElement.appendChild(document.createTextNode(cellData.text || cellData.value || ''));

@@ -46,0 +45,0 @@ cellElement.appendChild(divElement);

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