abstract-image
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -8,6 +8,6 @@ "use strict"; | ||
var cb = callbacks || {}; | ||
var id = Math.random().toString(); | ||
var id = "ai_root"; | ||
return (React.createElement("svg", { id: id, width: image.size.width + "px", height: image.size.height + "px", viewBox: [0, 0, image.size.width, image.size.height].join(" "), onClick: _callback(cb.onClick, id), onDoubleClick: _callback(cb.onDoubleClick, id), onMouseMove: _callback(cb.onMouseMove, id), onContextMenu: _callback(cb.onContextMenu, id) }, R.unnest(R.addIndex(R.map)( | ||
// tslint:disable-next-line:no-any | ||
function (c, i) { return _visit(i.toString(), c, id); }, image.components)))); | ||
function (c, i) { return _visit(i.toString(), c); }, image.components)))); | ||
} | ||
@@ -28,7 +28,7 @@ exports.createReactSvg = createReactSvg; | ||
} | ||
function makeIdAttr(id, rootId) { | ||
function makeIdAttr(id) { | ||
if (!id) { | ||
return undefined; | ||
} | ||
return "ai" + rootId + "%" + id; | ||
return "ai%" + id; | ||
} | ||
@@ -41,3 +41,3 @@ function getIdAttr(target, rootId) { | ||
var parts = id.split("%"); | ||
if (parts.length !== 2 || parts[0] !== "ai" + rootId) { | ||
if (parts.length !== 2 || parts[0] !== "ai") { | ||
return getIdAttr(target.parentNode || undefined, rootId); | ||
@@ -47,3 +47,3 @@ } | ||
} | ||
function _visit(key, component, rootId) { | ||
function _visit(key, component) { | ||
switch (component.type) { | ||
@@ -54,3 +54,3 @@ case "group": | ||
// tslint:disable-next-line:no-any | ||
function (c, i) { return _visit(i.toString(), c, rootId); }, component.children))) | ||
function (c, i) { return _visit(i.toString(), c); }, component.children))) | ||
]; | ||
@@ -61,3 +61,3 @@ case "binaryimage": | ||
return [ | ||
React.createElement("g", { key: key, id: makeIdAttr(component.id, rootId), dangerouslySetInnerHTML: { | ||
React.createElement("g", { key: key, id: makeIdAttr(component.id), dangerouslySetInnerHTML: { | ||
__html: component.data.reduce(function (a, b) { return a + String.fromCharCode(b); }, "") | ||
@@ -71,3 +71,3 @@ } }) | ||
return [ | ||
React.createElement("line", { id: makeIdAttr(component.id, rootId), key: key, x1: component.start.x, y1: component.start.y, x2: component.end.x, y2: component.end.y, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor) }) | ||
React.createElement("line", { id: makeIdAttr(component.id), key: key, x1: component.start.x, y1: component.start.y, x2: component.end.x, y2: component.end.y, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor) }) | ||
]; | ||
@@ -116,3 +116,3 @@ case "text": | ||
return [ | ||
React.createElement("ellipse", { id: makeIdAttr(component.id, rootId), key: key, cx: cx, cy: cy, rx: rx, ry: ry, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
React.createElement("ellipse", { id: makeIdAttr(component.id), key: key, cx: cx, cy: cy, rx: rx, ry: ry, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
]; | ||
@@ -124,3 +124,3 @@ case "polyline": | ||
return [ | ||
React.createElement("polyline", { id: makeIdAttr(component.id, rootId), key: key, points: linePoints, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), fill: "none" }) | ||
React.createElement("polyline", { id: makeIdAttr(component.id), key: key, points: linePoints, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), fill: "none" }) | ||
]; | ||
@@ -132,7 +132,7 @@ case "polygon": | ||
return [ | ||
React.createElement("polygon", { id: makeIdAttr(component.id, rootId), key: key, points: points, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
React.createElement("polygon", { id: makeIdAttr(component.id), key: key, points: points, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
]; | ||
case "rectangle": | ||
return [ | ||
React.createElement("rect", { id: makeIdAttr(component.id, rootId), key: key, x: component.topLeft.x, y: component.topLeft.y, width: Math.abs(component.bottomRight.x - component.topLeft.x), height: Math.abs(component.bottomRight.y - component.topLeft.y), stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
React.createElement("rect", { id: makeIdAttr(component.id), key: key, x: component.topLeft.x, y: component.topLeft.y, width: Math.abs(component.bottomRight.x - component.topLeft.x), height: Math.abs(component.bottomRight.y - component.topLeft.y), stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
]; | ||
@@ -139,0 +139,0 @@ default: |
@@ -6,6 +6,6 @@ import * as R from "ramda"; | ||
var cb = callbacks || {}; | ||
var id = Math.random().toString(); | ||
var id = "ai_root"; | ||
return (React.createElement("svg", { id: id, width: image.size.width + "px", height: image.size.height + "px", viewBox: [0, 0, image.size.width, image.size.height].join(" "), onClick: _callback(cb.onClick, id), onDoubleClick: _callback(cb.onDoubleClick, id), onMouseMove: _callback(cb.onMouseMove, id), onContextMenu: _callback(cb.onContextMenu, id) }, R.unnest(R.addIndex(R.map)( | ||
// tslint:disable-next-line:no-any | ||
function (c, i) { return _visit(i.toString(), c, id); }, image.components)))); | ||
function (c, i) { return _visit(i.toString(), c); }, image.components)))); | ||
} | ||
@@ -25,7 +25,7 @@ function _callback(callback, rootId) { | ||
} | ||
function makeIdAttr(id, rootId) { | ||
function makeIdAttr(id) { | ||
if (!id) { | ||
return undefined; | ||
} | ||
return "ai" + rootId + "%" + id; | ||
return "ai%" + id; | ||
} | ||
@@ -38,3 +38,3 @@ function getIdAttr(target, rootId) { | ||
var parts = id.split("%"); | ||
if (parts.length !== 2 || parts[0] !== "ai" + rootId) { | ||
if (parts.length !== 2 || parts[0] !== "ai") { | ||
return getIdAttr(target.parentNode || undefined, rootId); | ||
@@ -44,3 +44,3 @@ } | ||
} | ||
function _visit(key, component, rootId) { | ||
function _visit(key, component) { | ||
switch (component.type) { | ||
@@ -51,3 +51,3 @@ case "group": | ||
// tslint:disable-next-line:no-any | ||
function (c, i) { return _visit(i.toString(), c, rootId); }, component.children))) | ||
function (c, i) { return _visit(i.toString(), c); }, component.children))) | ||
]; | ||
@@ -58,3 +58,3 @@ case "binaryimage": | ||
return [ | ||
React.createElement("g", { key: key, id: makeIdAttr(component.id, rootId), dangerouslySetInnerHTML: { | ||
React.createElement("g", { key: key, id: makeIdAttr(component.id), dangerouslySetInnerHTML: { | ||
__html: component.data.reduce(function (a, b) { return a + String.fromCharCode(b); }, "") | ||
@@ -68,3 +68,3 @@ } }) | ||
return [ | ||
React.createElement("line", { id: makeIdAttr(component.id, rootId), key: key, x1: component.start.x, y1: component.start.y, x2: component.end.x, y2: component.end.y, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor) }) | ||
React.createElement("line", { id: makeIdAttr(component.id), key: key, x1: component.start.x, y1: component.start.y, x2: component.end.x, y2: component.end.y, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor) }) | ||
]; | ||
@@ -113,3 +113,3 @@ case "text": | ||
return [ | ||
React.createElement("ellipse", { id: makeIdAttr(component.id, rootId), key: key, cx: cx, cy: cy, rx: rx, ry: ry, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
React.createElement("ellipse", { id: makeIdAttr(component.id), key: key, cx: cx, cy: cy, rx: rx, ry: ry, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
]; | ||
@@ -121,3 +121,3 @@ case "polyline": | ||
return [ | ||
React.createElement("polyline", { id: makeIdAttr(component.id, rootId), key: key, points: linePoints, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), fill: "none" }) | ||
React.createElement("polyline", { id: makeIdAttr(component.id), key: key, points: linePoints, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), fill: "none" }) | ||
]; | ||
@@ -129,7 +129,7 @@ case "polygon": | ||
return [ | ||
React.createElement("polygon", { id: makeIdAttr(component.id, rootId), key: key, points: points, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
React.createElement("polygon", { id: makeIdAttr(component.id), key: key, points: points, stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
]; | ||
case "rectangle": | ||
return [ | ||
React.createElement("rect", { id: makeIdAttr(component.id, rootId), key: key, x: component.topLeft.x, y: component.topLeft.y, width: Math.abs(component.bottomRight.x - component.topLeft.x), height: Math.abs(component.bottomRight.y - component.topLeft.y), stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
React.createElement("rect", { id: makeIdAttr(component.id), key: key, x: component.topLeft.x, y: component.topLeft.y, width: Math.abs(component.bottomRight.x - component.topLeft.x), height: Math.abs(component.bottomRight.y - component.topLeft.y), stroke: colorToRgb(component.strokeColor), strokeWidth: component.strokeThickness, strokeOpacity: colorToOpacity(component.strokeColor), opacity: colorToOpacity(component.fillColor), fill: colorToRgb(component.fillColor) }) | ||
]; | ||
@@ -136,0 +136,0 @@ default: |
{ | ||
"name": "abstract-image", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Dynamically create images using code or JSX and render to any format", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image", |
@@ -0,0 +0,0 @@ # abstract-image |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
146332